侧边栏壁纸
博主头像
最闪啊姚凌武!博主等级

天下武功,唯快不破

  • 累计撰写 293 篇文章
  • 累计创建 34 个标签
  • 累计收到 10 条评论

目 录CONTENT

文章目录

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

姚凌武
2017-01-03 / 0 评论 / 0 点赞 / 12 阅读 / 6533 字
[java] view plain copy
  1. /**
  2.  * 跳转到miui的权限管理页面
  3.  */
  4. private void gotoMiuiPermission() {
  5.     Intent i = new Intent("miui.intent.action.APP_PERM_EDITOR");
  6.     ComponentName componentName = new ComponentName("com.miui.securitycenter""com.miui.permcenter.permissions.AppPermissionsEditorActivity");
  7.     i.setComponent(componentName);
  8.     i.putExtra("extra_pkgname", getPackageName());
  9.     try {
  10.         startActivity(i);
  11.     } catch (Exception e) {
  12.         e.printStackTrace();
  13.         gotoMeizuPermission();
  14.     }
  15. }
接下来上魅族的代码
[java] view plain copy
  1. /**
  2.  * 跳转到魅族的权限管理系统
  3.  */
  4. private void gotoMeizuPermission() {
  5.     Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
  6.     intent.addCategory(Intent.CATEGORY_DEFAULT);
  7.     intent.putExtra("packageName", BuildConfig.APPLICATION_ID);
  8.     try {
  9.         startActivity(intent);
  10.     } catch (Exception e) {
  11.         e.printStackTrace();
  12.         gotoHuaweiPermission();
  13.     }
  14. }
华为的系统由于不太一样,有些系统是华为自己的权限管理,而6.0的是用的原生的权限管理页面,目前手上只有一台6.0的华为手机, 暂时没有研究到打开的方法,如果有知道的大神麻烦告知一下 不过打不开没关系,我们可以退而求其次,打开所用应用的权限管理页面
[java] view plain copy
  1. /**
  2.  * 华为的权限管理页面
  3.  */
  4. private void gotoHuaweiPermission() {
  5.     try {
  6.         Intent intent = new Intent();
  7.         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  8.         ComponentName comp = new ComponentName("com.huawei.systemmanager""com.huawei.permissionmanager.ui.MainActivity");//华为权限管理
  9.         intent.setComponent(comp);
  10.         startActivity(intent);
  11.     } catch (Exception e) {
  12.         e.printStackTrace();
  13.         startActivity(getAppDetailSettingIntent());
  14.     }
  15. }
目前也就研究了这三大系统,对于原生系统,和其他系统,如果找不到方法,也可以先把用户引导到系统设置页面
[java] view plain copy
  1. /**
  2.  * 获取应用详情页面intent
  3.  *
  4.  * @return
  5.  */
  6. private Intent getAppDetailSettingIntent() {
  7.     Intent localIntent = new Intent();
  8.     localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  9.     if (Build.VERSION.SDK_INT >= 9) {
  10.         localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
  11.         localIntent.setData(Uri.fromParts("package", getPackageName(), null));
  12.     } else if (Build.VERSION.SDK_INT <= 8) {
  13.         localIntent.setAction(Intent.ACTION_VIEW);
  14.         localIntent.setClassName("com.android.settings""com.android.settings.InstalledAppDetails");
  15.         localIntent.putExtra("com.android.settings.ApplicationPkgName", getPackageName());
  16.     }
  17.     return localIntent;
  18. }
0

评论区