Android判断app是否打开消息通知并跳转设置
16lz
2021-01-23
1、判断是否打开
NotificationManagerCompat notification = NotificationManagerCompat.from(this);boolean isEnabled = notification.areNotificationsEnabled();
2、跳转系统设置
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BASE) { // 进入设置系统应用权限界面 Intent intent = new Intent(Settings.ACTION_SETTINGS); startActivity(intent); return;} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {// 运行系统在5.x环境使用 // 进入设置系统应用权限界面 Intent intent = new Intent(Settings.ACTION_SETTINGS); startActivity(intent); return;}
跳转应用系统设置
public static final String SETTINGS_ACTION = "android.settings.APPLICATION_DETAILS_SETTINGS";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BASE) { Intent intent = new Intent() .setAction(SETTINGS_ACTION) .setData(Uri.fromParts("package", getApplicationContext().getPackageName(), null)); startActivity(intent); return; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent() .setAction(SETTINGS_ACTION) .setData(Uri.fromParts("package", getApplicationContext().getPackageName(), null)); startActivity(intent); return; }
更多相关文章
- android 打开app先显示欢迎界面后自动跳到主界面
- Android使用Fragment嵌套Fragment的模式实现界面滑动
- Android 读取安装的非系统应用程序
- Android编译系统详解 配置文件
- Android 开机自启和后台自启权限
- Android获得系统时间(24小时制)
- Android Service中判断系统全屏