get Package Information Permission - Android App

Android examples for App:Package

Description

get Package Information Permission

Demo Code


import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class Main {
  public static PackageInfo getPackageInfoPerms(PackageManager pm, String name) {
    PackageInfo ret = null;//from  w  w  w .  ja  va  2 s.  c  om
    try {
      ret = pm.getPackageInfo(name, PackageManager.GET_PERMISSIONS);
    } catch (NameNotFoundException e) {
      // e.printStackTrace();
    }
    return ret;
  }

  public static PackageInfo getPackageInfo(PackageManager pm, String name) {
    PackageInfo ret = null;
    try {
      ret = pm.getPackageInfo(name, PackageManager.GET_ACTIVITIES);
    } catch (NameNotFoundException e) {
      // e.printStackTrace();
    }
    return ret;
  }
}

Related Tutorials