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

删除回忆录丶 提交于 2019-12-11 20:38:00

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/16956904/how-to-detect-app-launching-event-in-android-and-start-broadcast-reciever

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!