Android判断app是否打开消息通知并跳转设置
16lz
2022-05-26
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(安卓)开机自启和后台自启权限
- android 6.0 创建文件或文件夹失败
- Android(安卓)GridView 例子
- Android下基于OpenGL的程序会发生纹理丢失的原因
- Android(安卓)APP 启动时间统计
- Android判断是否有网络连接
- Android(安卓)读取安装的非系统应用程序
- Android样式设计
- AndroidManifest.xml文件详解(supports-screens)