get Permission Info String Map - Android App

Android examples for App:Manifest

Description

get Permission Info String Map

Demo Code


//package com.java2s;
import java.util.ArrayList;

import java.util.HashMap;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionInfo;
import android.util.Log;

public class Main {
    public static HashMap<String, ArrayList<PackageInfo>> mPermissionAppMap;
    public static HashMap<String, PermissionInfo> mPermissionInfoStringMap;
    public static PackageManager mPM;
    private final static String TAG = "PackageInfoHelper";

    private static void getPermissionInfoStringMap() {
        if (mPermissionInfoStringMap != null)
            return;

        mPermissionInfoStringMap = new HashMap<String, PermissionInfo>();

        for (String permission : mPermissionAppMap.keySet()) {
            try {
                PermissionInfo tmpPermInfo = mPM.getPermissionInfo(
                        permission, 0);// www. ja v  a  2 s . co m
                if (tmpPermInfo != null) {
                    mPermissionInfoStringMap.put(permission, tmpPermInfo);
                }
            } catch (NameNotFoundException e) {
                Log.i(TAG, "Ignoring unknown permission:" + permission);
            }
        }
    }
}

Related Tutorials