应用检查后台启动权限的方法如下: public static boolean canBackgroundStart(Context context) { AppOpsManager ops = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); try { int op = 10021; // >= 23 // ops.checkOpNoThrow(op, uid, packageName) Method method = ops.getClass().getMethod("checkOpNoThrow", new Class[] {int.class, int.class, String.class} ); Integer result = (Integer) method.invoke(ops, op, Process.myUid(), context.getPackageName()); return result == AppOpsManager.MODE_ALLOWED; } catch (Exception e) { Log.e(TAG, "not support", e); } return false; }
该方法是申请“后台弹出页面”权限白名单时小米官方给出的检查后台启动权限的方法。
需要的朋友拿走