Detect when user launches a new application on an Android device

后端 未结 2 450
攒了一身酷
攒了一身酷 2021-01-03 16:00

I have been trying to detect when the user launches an application on his/her device.

So I found this solution:

https://stackoverflow.com/a/7239840/833219

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 16:26

    Reading the logs is a horrible idea, and also broken across versions of the system. There is actually a broadcast intent for which you can register here: ACTION_PACKAGE_FIRST_LAUNCH, however, take note that this is only available in API level 12+.

提交回复
热议问题