Reputation: 1621
How can I receive a notification whenever a user is opening and closing any application on the phone?
Upvotes: 1
Views: 851
Reputation: 64429
Depends on what you want. Inside the application: ofcourse. you can find out if your own application is getting opened or closed using the function from the lifecycle.
Using the same functions you can deduce you are being send to the background, so that's a bit like finding out something is happening, although it doesn't need to be another app (it could just be 'home'). Also, you won't get the notice what app is being run.
As far as I know there is no "this application is being started" trigger, but you could go the long way around: just like taskkillers do, you can ofcourse find out what tasks are being run. If one is added, then you can kind-off be sure it is being started, and so there you could create some sort of trigger for yourself. But this sounds a bit like a hack.
Maybe you want to expand on your goal, and check out of there are other sollutions?
Upvotes: 2