1

I'm trying to develop an application launcher application for android. I'm in the very beginning but I have a problem here: How do I get a list of all installed applications in android?

tstenner
  • 9,119
  • 10
  • 48
  • 83
Midhun VP
  • 633
  • 1
  • 10
  • 17
  • 3
    Exact duplicate: http://stackoverflow.com/questions/2695746/how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run – SERPRO Feb 22 '12 at 11:15

2 Answers2

3

Use these methods in your activty to get a list of installed applications.

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

    private ArrayList<PackageInfoStruct> getInstalledApps(boolean getSysPackages) {

        List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
        try{
            app_labels = new String[packs.size()];
        }catch(Exception e){
            Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
        }
        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());
            res.add(newInfo);

            app_labels[i] = newInfo.appname;
        }
        return res;
    }
COD3BOY
  • 11,484
  • 1
  • 34
  • 55
Rakshi
  • 6,487
  • 3
  • 23
  • 46
1

I'd suggest you to atleast search stackoverflow before posting a question.

From a duplicate question : via @karan

Following is the code to get the list of activities/applications installed on Android :

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
Community
  • 1
  • 1
COD3BOY
  • 11,484
  • 1
  • 34
  • 55