0

When I click on "Home" button, it will display applications which I open and haven't been killed on the background.

Example: First, I open WhatsApp and then go to home screen without killing it. Then I open Facebook and do the same again. Do the same with 3 or 4 other applications. Now, when I click the "Home" button or app button at that time, it will display all the applications which are in background in ListView.

So, my question is: How to do this when I click any of the button or "Home" button on Android device?

Image

list of apps displayed from Home button

Andrew T.
  • 4,701
  • 8
  • 43
  • 62

2 Answers2

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

   for (int i = 0; i < recentTasks.size(); i++) {
       Log.d("RUNNING", "Application (" +i+")" +recentTasks.get(i).baseActivity.toShortString()+ "\t\t ID: "+recentTasks.get(i).id+"");         
   }
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
0

To check all Apps/Services running:

private void whichServiceRunning() {
  ActivityManager actiManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo serviceInfo : actiManager.getRunningServices(Integer.MAX_VALUE)) {          
            Log.d("RUNNING: ", serviceInfo.service.getPackageName());
        }
}

I hope this helps you

Ciro Rizzo
  • 492
  • 4
  • 8