-1

I am trying this method but it is deprecated.

ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(Integer.MAX_VALUE);

for (int i = 0; i < tasks.size(); i++) {
    Log.e("Running task", "Running task: " + tasks.get(i).baseActivity.toShortString() + "\t\t ID: " + tasks.get(i).id);
}
Cœur
  • 34,719
  • 24
  • 185
  • 251
Kdon Patel
  • 99
  • 1
  • 15
  • not working only launcher app and app that I have developed is listing – Kdon Patel Nov 19 '19 at 07:02
  • Then i think this have the same problem as yours: https://stackoverflow.com/questions/37974894/why-i-cant-see-all-running-apps-in-android-programmatically . The OP in this question, commented in one of the answers that this solved his/her problem: https://stackoverflow.com/questions/30619349/android-5-1-1-and-above-getrunningappprocesses-returns-my-application-packag/32366476#32366476 – Nathan Nov 19 '19 at 07:34

2 Answers2

-2

You can try this:

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> pkgAppsList = 
context.getPackageManager().queryIntentActivities( mainIntent, 0);
Dino
  • 6,957
  • 8
  • 35
  • 75
Tanzeem Iqbal
  • 105
  • 1
  • 6
-2

Here is an easy way to get the list of all installed apps

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

for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG, "Source dir : " + packageInfo.sourceDir);
Log.d(TAG, "Launch Activity :" + 
pm.getLaunchIntentForPackage(packageInfo.packageName)); 
}
Dino
  • 6,957
  • 8
  • 35
  • 75
Tanzeem Iqbal
  • 105
  • 1
  • 6