Example usage for android.content.pm PackageManager getAllPermissionGroups

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

Introduction

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

Prototype

public abstract List<PermissionGroupInfo> getAllPermissionGroups(@PermissionGroupInfoFlags int flags);

Source Link

Document

Retrieve all of the known permission groups in the system.

Usage

From source file:Main.java

public static void printAllPermission(Context context) {
    if (!debug) {
        return;//from  w w w .  j  a v a2  s .  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();
        }
    }
}