2

I want to create a service (or a broadcast)in my application that detect when the user select any application in the device. So my service will detect that a new application was started.

Is that possible?

haythem souissi
  • 3,263
  • 7
  • 50
  • 77

1 Answers1

3

You should use getRunningAppProcesses() to load the list of running apps and check the variation in this list.

see this link

another solution is to analyze logcat output

see first answer to this question

Community
  • 1
  • 1
Silverstorm
  • 15,398
  • 2
  • 38
  • 52
  • yes, but i want to get the new running application when it exactly run. i can not check all RunningAppProcesses every time. – haythem souissi May 30 '12 at 00:59
  • i putted this : ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); List runningAppProcessInfo = am.getRunningAppProcesses(); in my service , in the onStartCommand. and my application was blocked (ANR) Application Not Responding!!! – haythem souissi May 30 '12 at 01:00
  • 1
    ok, in this case you should try to use logcat and analyze it's output in the right way, see the answer at this [link](http://stackoverflow.com/questions/3290936/android-detect-when-other-apps-are-launched) – Silverstorm May 30 '12 at 01:19
  • thanks, i have seen this code. But i can't figure out were to put it? can you please help me? where do we have to put this code? in a service? in the onStartCommand()? – haythem souissi May 30 '12 at 01:27