Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show details for installed application on Android?

Tags:

android

I am writing an app for listing applications installed on the system. I am using PackageManager and queryIntentActivities() to get list of applications.

I am able to start it, uninstall it (using ACTION_DELETE), but I have no idea how to show details (where user can force stop, move to/from SD card, see disk space usage etc)?

I tried ACTION_VIEW, but it also shows uninstall dialog on 2.1 (did not check other versions yet). I also didn't find anything except for an unanswered question on android-dev mailing list.

like image 658
wojciechka Avatar asked Apr 04 '11 08:04

wojciechka


2 Answers

Solution combined with answer above and http://groups.google.com/group/android-developers/browse_thread/thread/1d4607eb370b1fe6/3cd4b85c310fe112?show_docid=3cd4b85c310fe112&pli=1:

    Intent intent;

    if (android.os.Build.VERSION.SDK_INT >= 9) {
        /* on 2.3 and newer, use APPLICATION_DETAILS_SETTINGS with proper URI */
        Uri packageURI = Uri.parse("package:" + pkgName);
        intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", packageURI);
        ctx.startActivity(intent);
    }  else  {
        /* on older Androids, use trick to show app details */
        intent = new Intent(Intent.ACTION_VIEW); 
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); 
        intent.putExtra("com.android.settings.ApplicationPkgName", pkgName); 
        intent.putExtra("pkg", pkgName); 
        ctx.startActivity(intent);          
    }
like image 138
wojciechka Avatar answered Nov 03 '22 01:11

wojciechka


Starting with API Level 9 (a.k.a., Android 2.3), you should be able to use ACTION_APPLICATION_DETAILS_SETTINGS for this. There is no way to get to this screen in previous versions of Android.

like image 41
CommonsWare Avatar answered Nov 03 '22 01:11

CommonsWare