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; }