-3

I am developing an android application that will display all the applications installed in the mobile phone and when clicking on a particular application, it should show only permissions of that application. I used package manager to fetch the details of all the details of the apk's installed. The part of the code is here:

    PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> applist = packageManager.getInstalledPackages(0);
    Iterator<PackageInfo> it = applist.iterator();
    while (it.hasNext()) {
        PackageInfo pk = (PackageInfo) it.next();
        PackageInfo pk1 = (PackageInfo) it.next();



        if ((pk.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            // Log.v("System app using internet = ",""+ pk.applicationInfo.loadLabel(packageManager));
            String p = pk.applicationInfo.loadLabel(packageManager).toString();

            if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(Manifest.permission.CAMERA, pk.packageName))
                //results.add("" +"\n"+pk.applicationInfo.loadLabel(packageManager));





            {
                //Drawable appicon = getPackageManager().getApplicationIcon("com.google.maps");
                results.add("" + "\n" + pk.applicationInfo.loadLabel(packageManager));
            }
            if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, pk.packageName))
                results1.add("" +"\n"+pk1.applicationInfo.loadLabel(packageManager));
        }

    }

I should get the icons followed by the application name while listing the applications.

Icon and application name example How should I modify this code so that the required output is got.

  • 1
    try https://stackoverflow.com/questions/25244456/read-permission-of-installed-application-in-android-phone – D.J Nov 21 '17 at 10:17

1 Answers1

0

Example app

Official document

core code:

packageInfo.requestedPermissions?.forEach { permission -> ... }

More links

https://developer.android.com/reference/android/Manifest.permission.html

https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml

http://androidpermissions.com/

Dewey Reed
  • 4,353
  • 2
  • 27
  • 41