在Android设备上检索已安装应用的各种权限?

时间:2014-10-25 04:35:39

标签: java android android-intent permissions android-permissions

所有 我想知道如何编写扫描并检索Android上已安装应用程序所有权限的应用程序?

提前感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);

for (Object obj : pkgAppsList) {
  ResolveInfo resolveInfo = (ResolveInfo) obj;
  PackageInfo packageInfo = null;
  try { 
    packageInfo = getPackageManager().getPackageInfo(resolveInfo.activityInfo.packageName, PackageManager.GET_PERMISSIONS);
  } catch (NameNotFoundException e) {
    // TODO Auto-generated catch block 
    e.printStackTrace();
  } 

  String[] requestedPermissions = packageInfo.requestedPermissions;
}   

来源:How to get manifest permissions of any installed Android app