Example usage for android.content.pm PackageManager queryPermissionsByGroup

List of usage examples for android.content.pm PackageManager queryPermissionsByGroup

Introduction

In this page you can find the example usage for android.content.pm PackageManager queryPermissionsByGroup.

Prototype

public abstract List<PermissionInfo> queryPermissionsByGroup(String group, @PermissionInfoFlags int flags)
        throws NameNotFoundException;

Source Link

Document

Query for all of the permissions associated with a particular group.

Usage

From source file:Main.java

public static void printAllPermission(Context context) {
    if (!debug) {
        return;/* w  w  w  . j  a  va 2s .  c  o  m*/
    }
    PackageManager pm = context.getPackageManager();
    CharSequence csPermissionGroupLabel;
    CharSequence csPermissionLabel;
    List<PermissionGroupInfo> lstGroups = pm.getAllPermissionGroups(PackageManager.GET_PERMISSIONS);
    for (PermissionGroupInfo pgi : lstGroups) {
        csPermissionGroupLabel = pgi.loadLabel(pm);
        Log.d("ldx", "PermissionGroup: " + pgi.name + "  [" + csPermissionGroupLabel.toString() + "]");
        try {
            List<PermissionInfo> lstPermissions = pm.queryPermissionsByGroup(pgi.name, 0);
            for (PermissionInfo pi : lstPermissions) {
                csPermissionLabel = pi.loadLabel(pm);
                Log.d("ldx", "     PermissionChild" + pi.name + "  [" + csPermissionLabel.toString() + "]");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}