-1

How can I get all installed applications listed into a listView. I tried the following code and others but it does not work well

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);  
    final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
}

and I'm still not understanding why to use intent in this manner.

Prerak Sola
  • 8,401
  • 5
  • 29
  • 55
20050
  • 11
  • 5

1 Answers1

1

you can do this :

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


    for (ApplicationInfo packageInfo : packages) {
        Log.e(TAG, "Installed package :" + packageInfo.packageName);
        Log.e(TAG, "Source dir : " + packageInfo.sourceDir);
        Log.e(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName)); 
        Log.e(TAG, "");
    }

by using packages list file

i always use this code , i hope you enjoy it

Adnan Abdollah Zaki
  • 3,238
  • 5
  • 44
  • 53