如何检测应用的启动事件在Android和启动广播reciever [英] 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?
先谢谢了。
推荐答案
有没有广播时应用启动就知道了。你可以有定期检查当前正在运行的任务列表中的服务运行,看是否有特定的应用程序已经启动。
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.
您可以了解从这里的服务: http://developer.android。 COM /参考/安卓/应用/ Service.html
You can learn about services from here : http://developer.android.com/reference/android/app/Service.html
您可以获取正在运行的任务从getRunningTasks名单()的ActivityManager的方法。
You can get the list of running tasks from getRunningTasks() method of the ActivityManager.
这篇关于如何检测应用的启动事件在Android和启动广播reciever的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!