androidpermissions

How to get the icon for an Android permission?


The XML spec for <permission> and <permission-group> refers to an icon which you see in Settings | App info | Permissions.

If I already have the permission an app needs in the from of a string from querying the PackageInfo, for example "android.permission.INTERNET", how can I get the associated permission and permission-group icon?


Solution

  • According to this, following approach should work: http://developer.android.com/reference/android/content/pm/PackageManager.html

    PackageManager pm = context.getPackageManager();
    PermissionInfo info = pm.getPermissionInfo("PERMISSION_NAME", OPTIONAL_FLAGS);
    int drawableResource = info.icon;
    

    There's also a method in PackageManager called getPermissionGroupInfo.