Created
May 18, 2018 21:09
-
-
Save rodrigoborgesdeoliveira/c4b4041ebfcb373413e053da2f274491 to your computer and use it in GitHub Desktop.
Get all android apps requested permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
carynvidiashield
commented
Feb 20, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment