日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android app没有读写权限设置,Android 6.0以上权限拒绝打开权限设置界面的解决方法...

發布時間:2025/3/12 Android 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android app没有读写权限设置,Android 6.0以上权限拒绝打开权限设置界面的解决方法... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本人使用小米手機,打開qq或者微信的時候,某個權限拒絕的話,會提示你開啟,點擊開啟會跳轉到app的權限設置界面,當然了,這是國內系統深層定制的原因,也就是說這個界面原聲的android沒有的!這里以小米和魅族作為示例講解如何讓用戶手動打開權限,當然了如果是原聲的android就讓他跳轉到應用的詳情設置頁面(有點坑,因為普通用戶還是不知道怎么整)。

參考了很多零零碎碎的東西,網址已經找不到了。。。。。。

ok,第一步是跳轉到系統的界面,下面基本上可以從9開始考慮了,可以簡化。

String SCHEME = "package";

//調用系統InstalledAppDetails界面所需的Extra名稱(用于Android 2.1及之前版本)

final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName";

//調用系統InstalledAppDetails界面所需的Extra名稱(用于Android 2.2)

final String APP_PKG_NAME_22 = "pkg";

//InstalledAppDetails所在包名

final String APP_DETAILS_PACKAGE_NAME = "com.android.settings";

//InstalledAppDetails類名

final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails";

Intent intent = new Intent();

final int apiLevel = Build.VERSION.SDK_INT;

if (apiLevel >= 9) { // 2.3(ApiLevel 9)以上,使用SDK提供的接口

intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);

Uri uri = Uri.fromParts(SCHEME, getPackageName(), null);

intent.setData(uri);

} else { // 2.3以下,使用非公開的接口(查看InstalledAppDetails源碼)

// 2.2和2.1中,InstalledAppDetails使用的APP_PKG_NAME不同。

final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22

: APP_PKG_NAME_21);

intent.setAction(Intent.ACTION_VIEW);

intent.setClassName(APP_DETAILS_PACKAGE_NAME,

APP_DETAILS_CLASS_NAME);

intent.putExtra(appPkgName, getPackageName());

}

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent);

第二個,miui,首先你得判斷是miui,親自測試,MIUI7穩定版,MIUI8開發板本可行,工具類下面會提供下載

if (CheckPhoneSystemUtils.isMIUI()) {

MLog.i("產品/硬件的制造商小米:");

intent.setAction("miui.intent.action.APP_PERM_EDITOR");

intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");

intent.putExtra("extra_pkgname", getPackageName());

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

try {

startActivity(intent);

} catch (Exception e) {

e.printStackTrace();

Toast.makeText(MediaRecoderService.this, "只有MIUI才可以設置哦", Toast.LENGTH_SHORT).show();

}

}

第三個,flyme(由于沒有flyme機子),采用的云手機測試的

else if (CheckPhoneSystemUtils.isFlyme()) {

intent.setAction("com.meizu.safe.security.SHOW_APPSEC");

intent.addCategory(Intent.CATEGORY_DEFAULT);

intent.putExtra("packageName", getPackageName());

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

try {

startActivity(intent);

} catch (Exception e) {

e.printStackTrace();

Toast.makeText(MediaRecoderService.this, "只有Flyme才可以設置哦", Toast.LENGTH_SHORT).show();

}

}

下面是工具類:BuildProperties

public class BuildProperties {

private final Properties properties;

private BuildProperties() throws IOException {

properties = new Properties();

properties.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));

}

public boolean containsKey(final Object key) {

return properties.containsKey(key);

}

public boolean containsValue(final Object value) {

return properties.containsValue(value);

}

public Set> entrySet() {

return properties.entrySet();

}

public String getProperty(final String name) {

return properties.getProperty(name);

}

public String getProperty(final String name, final String defaultValue) {

return properties.getProperty(name, defaultValue);

}

public boolean isEmpty() {

return properties.isEmpty();

}

public Enumeration keys() {

return properties.keys();

}

public Set keySet() {

return properties.keySet();

}

public int size() {

return properties.size();

}

public Collection values() {

return properties.values();

}

public static BuildProperties newInstance() throws IOException {

return new BuildProperties();

}

CheckPhoneSystemUtils

private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";

private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";

private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";

/**

* 檢測MIUI

*

* @return

*/

public static boolean isMIUI() {

try {

final BuildProperties prop = BuildProperties.newInstance();

return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null || prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null || prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;

} catch (final IOException e) {

return false;

}

}

/**

* 檢測Flyme

*

* @return

*/

public static boolean isFlyme() {

try { // Invoke Build.hasSmartBar()

final Method method = Build.class.getMethod("hasSmartBar");

return method != null;

} catch (final Exception e) {

return false;

}

}

以上這篇Android 6.0以上權限拒絕打開權限設置界面的解決方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

總結

以上是生活随笔為你收集整理的android app没有读写权限设置,Android 6.0以上权限拒绝打开权限设置界面的解决方法...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。