How can one detect an Android application launching?

后端 未结 2 1211
星月不相逢
星月不相逢 2020-12-15 08:33

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

相关标签:
2条回答
  • 2020-12-15 09:18

    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.

    0 讨论(0)
  • 2020-12-15 09:19

    There aren't any broadcast intent when an application is launched for the general case. If the application you want to detect is yours, you can fire your own intent broadcast, but if not, then no, you can't detect it.

    0 讨论(0)
提交回复
热议问题