get Revoked Perms from PackageManager - Android android.content.pm

Android examples for android.content.pm:PackageManager

Description

get Revoked Perms from PackageManager

Demo Code


//package com.java2s;

import java.lang.reflect.Method;

import android.content.Context;
import android.content.pm.PackageManager;

public class Main {
    public static String[] getRevokedPerms(String packageName, Context ctx) {
        String[] revokedPerms = null;
        PackageManager pkgManager = ctx.getPackageManager();
        Method getRevokedPermissions;
        try {//from w  w  w.ja  v a  2s .  c om
            getRevokedPermissions = pkgManager.getClass().getMethod(
                    "getRevokedPermissions", java.lang.String.class);
            Object[] params = new Object[] { packageName };
            revokedPerms = (String[]) getRevokedPermissions.invoke(
                    pkgManager, params);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return revokedPerms;
    }
}

Related Tutorials