“Usage Stats” Permission throws error?
问题 I have been using this Stackoverflow answer to check if the user has already granted the "Usage Stats' permission: boolean granted = false; AppOpsManager appOps = (AppOpsManager) this .getSystemService(Context.APP_OPS_SERVICE); int mode = appOps.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, android.os.Process.myUid(), this.getPackageName()); if (mode == AppOpsManager.MODE_DEFAULT) { granted = (this.checkCallingOrSelfPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) ==