判断权限是否开启:
public class NoticePermissionUtil {
private static final String CHECK_OP_NO_THROW = "checkOpNoThrow";
private static final String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION";
//调用该方法获取是否开启通知栏权限
public static boolean isNotifyEnabled(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return isEnableV26(context);
} else {
return isEnabledV19(context);
}
}
/**
* 8.0以下判断
*
* @param context api19 4.4及以上判断
* @return
*/
private static boolean isEnabledV19(Context context) {
AppOpsManager mAppOps =
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
Applicati