整理下安卓跳转通知设置页面的代码,如下:
常量补充:
private static final String CHECK_OP_NO_THROW = "checkOpNoThrow";
private static final String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION";
1、android check通知是否开启代码
public static boolean isNotificationEnabled(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return isEnableV26(context);
} else {
return isEnableV19(context);
}
}
/**
* Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
* 19及以上
*
* @param context
* @return
*/
public static boolean isEnableV19(Context context) {
AppOpsManager mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
ApplicationInfo appInfo = context.getApplicationInfo();