Search code examples
androidservicebroadcastreceiver

how to detect app launching event in android and start broadcast reciever


I have to make a service which run in background with no icon of app and when any installed application is launched then my app detects and execute some functionality.

How can I achieve that?

Thanks in advance.


Solution

  • There is no broadcast to know when an app is launched. You can have a service running which has to periodically check the currently running tasks list to see if a particular app has been launched.

    You definitely can make the service run with no notification icon, but that will simply increase the probability of your service getting killed.

    You can learn about services from here : http://developer.android.com/reference/android/app/Service.html

    You can get the list of running tasks from getRunningTasks() method of the ActivityManager.