问题描述
是否有可能在执行程序的时候检测(即当用户点击应用程序的图标)?我试图注册类型的 Intent.ACTION_MAIN
使用类别类型的意图 Intent.CATEGORY_LAUNCHER
希望这将让我知道,每当一个应用程序被启动。问题是,我的广播接收装置,从未获取调用。
Is it possible to detect when an app is executed (i.e., when the user clicks on the app's icon)? I attempted to register an intent of type Intent.ACTION_MAIN
using a category of of type Intent.CATEGORY_LAUNCHER
hoping this would let me know whenever an app is launched. The problem is, my broadcast receiver is never getting called.
这是一个非法的意图/类别组合其中注册?有一些方法,我可以用它来确定何时应用程序启动时?
Is this an illegal intent/category combination for which to register? Is there some method I can use to determine when an application launch occurs?
推荐答案
应用程序启动意图不是广播,所以没有办法注册一个广播接收器和接收它。由于previously回答此处,实在是没有办法检测到启动应用程序的。你可能写调查正在运行的任务寻找应用程序的任务(使用ActivityManager接口)服务,但那是最好的,我能想到的,它可能不会是非常高性能的。
The application start Intent is not a broadcast, so there is no way to register a broadcast receiver and receive it. As previously answered here, there really is no way to detect the launch of the app. You could possibly write a service that polled the running tasks looking for the application's task (using the ActivityManager interface), but that's the best I can think of and it probably wouldn't be very performant.
这篇关于一个人怎么可以检测一个Android应用程序启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!