4

Does anybody have a simple code to display a list (list view?) of all the apps installed on a phone, and have the user open one when clicked?

Or even an App drawer. I just need a way to have the user open all of their apps.

I have tried searching for tutorials, but couldn't find any, and I downloaded the example home from Android, but I absolutely hate looking through code and digging out what I Want.

user802609
  • 799
  • 6
  • 19
  • 34

4 Answers4

4

Have a look at the Home sample application that comes with the SDK.

The basic idea is to use PackageManager to get either

  • a list of all installed packages using getInstalledPackages or
  • a list of all launcher activities using queryIntentActivities for an intent with category CATEGORY_LAUNCHER and action ACTION_MAIN

depending on your use case.

Roman Nurik
  • 29,665
  • 7
  • 84
  • 82
2

Here you can get all the installed application.Write code to achieve additional requirement

  List<ApplicationInfo> packages;
        PackageManager pm;
        pm = getPackageManager();
                 get a list of installed apps.
                packages = pm.getInstalledApplications(0);

    ActivityManager mActivityManager = (ActivityManager) context
                    .getSystemService(Context.ACTIVITY_SERVICE);

       for (ApplicationInfo packageInfo : packages) {
        //packageInfo.packageName is the name of the package


                          }
Rasel
  • 15,499
  • 6
  • 40
  • 50
0

Just check this code snippets posted here: http://www.androidsnippets.com/get-installed-applications-with-name-package-name-version-and-icon , you can have all the installed application.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
0

Rasel's Code worked ok for me.

Here is the full code: ( would love to see some more comments so I understand why it works!)

List<ApplicationInfo> packages;
        PackageManager pm = getPackageManager();
        packages= pm.getInstalledApplications(0);
        Log.v("Alert","package is "+packages);

        for (ApplicationInfo packageInfo : packages) {
            String tempinfo= packageInfo.packageName;
            Log.v("Alert","this is working"+ tempinfo);
UKDataGeek
  • 6,338
  • 9
  • 46
  • 63