中三A105论坛

注册 登录
查看: 774|回复: 0

android各大手机系统打开权限管理页面

[复制链接]

11

主题

21

帖子

77

积分

注册会员

Rank: 2

积分
77
发表于 2018-12-4 16:51:36 | 显示全部楼层 |阅读模式

[java] view plain copy




  • /**
  • * 跳转到miui的权限管理页面
  • */  
  • private void gotoMiuiPermission() {  
  •     Intent i = new Intent("miui.intent.action.APP_PERM_EDITOR");  
  •     ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");  
  •     i.setComponent(componentName);  
  •     i.putExtra("extra_pkgname", getPackageName());  
  •     try {  
  •         startActivity(i);  
  •     } catch (Exception e) {  
  •         e.printStackTrace();  
  •         gotoMeizuPermission();  
  •     }  
  • }  


接下来上魅族的代码




[java] view plain copy



  • /**
  • * 跳转到魅族的权限管理系统
  • */  
  • private void gotoMeizuPermission() {  
  •     Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");  
  •     intent.addCategory(Intent.CATEGORY_DEFAULT);  
  •     intent.putExtra("packageName", BuildConfig.APPLICATION_ID);  
  •     try {  
  •         startActivity(intent);  
  •     } catch (Exception e) {  
  •         e.printStackTrace();  
  •         gotoHuaweiPermission();  
  •     }  
  • }  


华为的系统由于不太一样,有些系统是华为自己的权限管理,而6.0的是用的原生的权限管理页面,目前手上只有一台6.0的华为手机,


暂时没有研究到打开的方法,如果有知道的大神麻烦告知一下

不过打不开没关系,我们可以退而求其次,打开所用应用的权限管理页面



[java] view plain copy



  • /**
  • * 华为的权限管理页面
  • */  
  • private void gotoHuaweiPermission() {  
  •     try {  
  •         Intent intent = new Intent();  
  •         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
  •         ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity");//华为权限管理  
  •         intent.setComponent(comp);  
  •         startActivity(intent);  
  •     } catch (Exception e) {  
  •         e.printStackTrace();  
  •         startActivity(getAppDetailSettingIntent());  
  •     }  
  •   
  • }  


目前也就研究了这三大系统,对于原生系统,和其他系统,如果找不到方法,也可以先把用户引导到系统设置页面




[java] view plain copy



  • /**
  • * 获取应用详情页面intent
  • *
  • * @return
  • */  
  • private Intent getAppDetailSettingIntent() {  
  •     Intent localIntent = new Intent();  
  •     localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
  •     if (Build.VERSION.SDK_INT >= 9) {  
  •         localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");  
  •         localIntent.setData(Uri.fromParts("package", getPackageName(), null));  
  •     } else if (Build.VERSION.SDK_INT <= 8) {  
  •         localIntent.setAction(Intent.ACTION_VIEW);  
  •         localIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");  
  •         localIntent.putExtra("com.android.settings.ApplicationPkgName", getPackageName());  
  •     }  
  •     return localIntent;  
  • }


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回列表 返回顶部