通知开关

1、获取系统通知开关状态

    private static boolean notificationCheckFor19Up(Context context){
        NotificationManagerCompat managerCompat = NotificationManagerCompat.from(context);
        return managerCompat.areNotificationsEnabled();
    }


2、跳转至系统应用页面

    public static void startAppSystemSetting(Context context){
        Intent localIntent = new Intent();
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (Build.VERSION.SDK_INT >= 9) {
            localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
            localIntent.setData(Uri.fromParts("package", context.getPackageName(), null));
        } else if (Build.VERSION.SDK_INT <= 8) {
            localIntent.setAction(Intent.ACTION_VIEW);
            localIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
            localIntent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
        }
        context.startActivity(localIntent);
    }

猜你喜欢

转载自blog.csdn.net/connor__ak/article/details/80898455