0

Possible Duplicate:
How to get the list of running applications?

How to get a list of active applications in Android? Thanks for answers.

Community
  • 1
  • 1
  • 3
    Try to copy your question, then paste it in google search-box, You would find this is a dup question : http://stackoverflow.com/questions/3304685/how-to-get-the-list-of-running-applications – wtsang02 Oct 28 '12 at 19:10

1 Answers1

0
ActivityManager manager = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> processes = manager.getRunningAppProcesses();

Then you have a collection of RunningAppProcessInfos, you probably want to be looking at this

Richard Taylor
  • 2,702
  • 2
  • 22
  • 44
  • So I get all running applications. I need only active! – Kirill Reutov Oct 29 '12 at 14:42
  • This might be a misconception of how things work. What do you define an 'active' process as? – Richard Taylor Oct 29 '12 at 14:47
  • How this application determines this? [Active Apps Ads](https://play.google.com/store/apps/details?id=com.elnware.ActiveAppsAds&feature=search_result) – Kirill Reutov Oct 29 '12 at 16:54
  • That is surely listing the running applications. There is no concept of 'Active' applications in Android. Either it's running, it's not running, or it's the on the foreground (your app). – Richard Taylor Oct 29 '12 at 16:59
  • As the application determines which applications are active? I use "getRunningTasks", but it determines that the launched three applications, but in the task manager there is nothing .. – Kirill Reutov Oct 29 '12 at 17:05
  • Are the three tasks you see normal apps, or something OS level? – Richard Taylor Oct 29 '12 at 17:23
  • I see task: the phone, the launcher .. They should not show, because it is background applications .. – Kirill Reutov Oct 29 '12 at 17:32
  • This is definitely a misunderstanding of how things work. The phone, is just an application, like any other. The launcher, is just an application, like any other. If the application is 'in the background', it's just not visible right now. All the applications are still running somewhere, so are in the running processes list. There is no such thing as 'Active'. – Richard Taylor Oct 29 '12 at 17:45
  • I would imagine that the ad blocking app you linked to, has a pre-defined list of applications to ignore (such as the Phone, Launcher), and that is the reason you're missing them from that list – Richard Taylor Oct 29 '12 at 17:46