Get List of All Installed Apps: Android

In this tutorial we will discuss how to get list of all installed apps in Android phone and how to launch application using  package name.

To get information about installed applications we will use PackageManager class of Android. For more detail about package manager visit PACKAGE MANAGER.

List<PackageInfo> apps = getPackageManager().getInstalledPackages(0)

getInstalledPackages method of getPackageManager class will return a list containing all the information about all the installed application.
Now we will extract the applications info from the list and store that information in arraylist.

ArrayList<AppInfo> res = new ArrayList<AppInfo>();
for(int i=0;i<apps.size();i++) {
                PackageInfo p = apps.get(i);

                AppInfo newInfo = new AppInfo();
                newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
                newInfo.pname = p.packageName;
                newInfo.versionName = p.versionName;
                newInfo.versionCode = p.versionCode;
                newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
                res.add(newInfo);
                }
            }

class AppInfo {
    String appname = "";
    String pname = "";
    String versionName = "";
    int versionCode = 0;
    Drawable icon;

}

Now we have an arraylist res which has all the information(application name, package name, version name, version code, application icon) of all the installed application in your android phone. You can display this information using list view or can print in logcat to check it.

Our last discussion of this tutorial, how to launch application using package name. You can do this using intent.

Intent LaunchApp = getPackageManager().getLaunchIntentForPackage(“package name”)
startActivity( LaunchApp );

Following is the link of a video which will demonstrate the result of our discussion.
Link: http://youtu.be/n10rMPDuEi4

You may also like

Tagged on: ,

3 thoughts on “Get List of All Installed Apps: Android

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>