views:

78

answers:

1

I want to write a service for Android platform that is notified when the current foreground activity changes. Basically the service should do some tasks only when the top activity changes. Is there any way to subscribe and to be notified when this kind of event occurs ? Or there is no possibility and the service should poll from time to time the list of running activities and to check what is the foreground activity ?Not preferable solution...

A: 

You should bind every activity to the service and you will know which activity is running.

fedj
Well this is not a solution, maybe I've expressed myself wrong, I want that the service be notified what application is running in the foreground (it could be any of the installed applications) and compare with a predefined list of applications and if it is on the list to do some work.
Alex
Ah ok, you wrote Activity so I understood that it was only one application. I really don't know how to do what you want to do sorry
fedj
Anyone else :) ?
Alex