這篇文章將為大家詳細講解有關(guān)如何解決Android 6.0以上權(quán)限拒絕打開權(quán)限設(shè)置界面的問題,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),恒山企業(yè)網(wǎng)站建設(shè),恒山品牌網(wǎng)站建設(shè),網(wǎng)站定制,恒山網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,恒山網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
實例如下
第一步是跳轉(zhuǎn)到系統(tǒng)的界面,下面基本上可以從9開始考慮了,可以簡化。
String SCHEME = "package";
//調(diào)用系統(tǒng)InstalledAppDetails界面所需的Extra名稱(用于Android 2.1及之前版本)
final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName";
//調(diào)用系統(tǒng)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穩(wěn)定版,MIUI8開發(fā)板本可行,工具類下面會提供下載
if (CheckPhoneSystemUtils.isMIUI()) {
MLog.i("產(chǎn)品/硬件的制造商小米:");
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才可以設(shè)置哦", 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才可以設(shè)置哦", 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<Map.Entry<Object, Object>> 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<Object> keys() {
return properties.keys();
}
public Set<Object> keySet() {
return properties.keySet();
}
public int size() {
return properties.size();
}
public Collection<Object> 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;
}
}關(guān)于“如何解決Android 6.0以上權(quán)限拒絕打開權(quán)限設(shè)置界面的問題”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
網(wǎng)站欄目:如何解決Android6.0以上權(quán)限拒絕打開權(quán)限設(shè)置界面的問題
路徑分享:http://www.chinadenli.net/article44/iishee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)站導(dǎo)航、網(wǎng)站收錄、企業(yè)網(wǎng)站制作、網(wǎng)站維護、虛擬主機
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)