Android 判断是否开启了应用权限

  • 判断是否开启应用权限方法
  • 如果没有开启应用权限,引导用户点击开启按钮,然后跳转到系统设置界面

判断是否开启应用权限方法

NotificationManagerCompat.from(context).areNotificationsEnabled();

如果没有开启应用权限,引导用户点击开启按钮,然后跳转到系统设置界面

private void goToSetting() {    Intent intent = new Intent();    if (Build.VERSION.SDK_INT >= 26) {// android 8.0引导        intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");        intent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName());    } else if (Build.VERSION.SDK_INT >= 21) { // android 5.0-7.0        intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");        intent.putExtra("app_package", getPackageName());        intent.putExtra("app_uid", getApplicationInfo().uid);    } else {//其它        intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");        intent.setData(Uri.fromParts("package", getPackageName(), null));    }    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);    startActivity(intent);}

更多相关文章

  1. appwidget中使按钮不能用 以及 appwidget初学指导
  2. 【Android】1.6版本所有权限
  3. Android 危险权限与所有权限大全
  4. Android 4.0为Launcher主界面所有应用程序图标添加统一背景主题
  5. Android控件ToggleButton多状态按钮使用详解
  6. Android基础:去掉app界面的标题-Title
  7. android 应用程序跳转到Settings的各个界面

随机推荐

  1. Android 曲线绘制Demo
  2. 使用Android(安卓)Studio的AVD进行测试
  3. Android adb不是内部或外部命令 问题解决
  4. Android Button Maker(在线生成android sh
  5. AndroidManifest.xml的Service元素 andro
  6. Android File文件操作
  7. android inputmanager中事件的传递流程
  8. android导航设计
  9. Android异步消息框架
  10. android中如何给button加圆角