How to get information about all the applications installed in your ANDROID Emulator or Phone? / How to use getPackageManager() in ANDROID ?

Hi all,
In this tutorial I will show you how to get the information about all the applications installed in your ANDROID phone.
What you have to do is create a ANDROID project inside the package pack.GetAllInstalledApplications amd name the java file “” and copy the following code into it.

Here the “getPackageManager().getInstalledPackages(0);” gets information about all the packages installed in your ANDROID Phone or emulator.
Now go on and try this.

package pack.GetAllInstalledApplications;

import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class GetAllInstalledApplicationsExample extends Activity {

	 public  ArrayList<packageInfoStruct> res = new ArrayList<packageInfoStruct>();
	 public ListView list;
	 public String app_labels[];

	 public void onCreate(Bundle savedInstanceState) {


	        list = (ListView)findViewById(;
				list.setAdapter(new ArrayAdapter<string>(this,
					android.R.layout.simple_dropdown_item_1line, app_labels));
			}catch(Exception e){
				System.out.println("Err ++> " + e.getMessage());

	private ArrayList<packageInfoStruct> getPackages() {
	    ArrayList<packageInfoStruct> apps = getInstalledApps(false);
	    final int max = apps.size();
	    for (int i=0; i < max; i++) {
	    return apps;

	private ArrayList<packageInfoStruct> getInstalledApps(boolean getSysPackages) {

	    List<packageInfo> packs = getPackageManager().getInstalledPackages(0);
	    	app_labels = new String[packs.size()];
	    }catch(Exception e){
	    for(int i=0;i < packs.size();i++) {
	        PackageInfo p = packs.get(i);
	        if ((!getSysPackages) && (p.versionName == null)) {
	            continue ;
	        PackageInfoStruct newInfo = new PackageInfoStruct();
	        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());

	        app_labels[i] = newInfo.appname;
	    return res;
/* This class is for storing the data for each application */
class PackageInfoStruct {
    String appname = "";
    String pname = "";
    String versionName = "";
    int versionCode = 0;
    Drawable icon;

The main.xml file

<?xml version="1.0" encoding="utf-8"?>
<linearLayout xmlns:android=""
    android:layout_height="fill_parent" >
 <listView android:id="@+id/ListView01"

The manifest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".GetAllInstalledApplicationsExample"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
Get all installed applications in your ANDROID Phone
Showin all applications installed in your ANDROID Phone or emulator

You can download the source code from here.

11 thoughts on “How to get information about all the applications installed in your ANDROID Emulator or Phone? / How to use getPackageManager() in ANDROID ?”

    1. Oh Ekjyot, Create an AVD with the Target as Google API in the Android AVD Manager. The AVD you currently using is not for Maps it is the normal Target.

  1. The above given code dont work . I have spend 5 hrs on this code but all in vain. So my request to others dont waste your time in using this code ….

    1. hello,
      I have an Error in ” try{
      list.setAdapter(new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, app_labels));
      } ”
      Error: The constructor ArrayAdapter(GetAllInstalledApplicationsExample, int, String[]) is undefined
      how can I resolve it?

  2. This was a perfect program for what I want but now i am trying to edit it so that it only displays the applications that needs internet permission.Anyone with a sugggestion of what i need to do?

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=""> <s> <strike> <strong>