Skip to content

Instantly share code, notes, and snippets.

@quiro91
Last active December 21, 2016 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quiro91/e0a524ca07d1453af2542f9f3478f48b to your computer and use it in GitHub Desktop.
Save quiro91/e0a524ca07d1453af2542f9f3478f48b to your computer and use it in GitHub Desktop.
private boolean checkForPermission(Context context) {
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
int mode = appOps.checkOpNoThrow(OPSTR_GET_USAGE_STATS, Process.myUid(), context.getPackageName());
return mode == MODE_ALLOWED;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment