Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get all android apps requested permissions
List<ApplicationInfo> packages = getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo applicationInfo : packages) {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);
// Get all requested permissions for the current for loop package
String[] requestedPermissions = packageInfo.requestedPermissions;
// It's also possible to get if a permission has been granted to the current for loop package.
// NOTE: Those permissions that are categorized as Special Access will always return true if the app has requested it.
// You can only see the correct value for these kind of permissions for your own app. Some examples of those permissions
// are android.Manifest.permission.SYSTEM_ALERT_WINDOW, android.Manifest.permission.PACKAGE_USAGE_STATS,
// android.permission.ACCESS_NOTIFICATION_POLICY
boolean isPermissionGranted = getPackageManager().checkPermission(android.Manifest.permission.ANY_COMMOM_PERMISSION_WITHOUT_SPECIAL_ACCESS,
packageInfo.packageName) == PackageManager.PERMISSION_GRANTED;
} catch (PackageManager.NameNotFoundException e) {
Log.e ("Any tag", "Couldn't find any package with that name", e.fillInStackTrace());
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment