Detect when user launches a new application on an Android device

后端 未结 2 451
攒了一身酷
攒了一身酷 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:40

    you can detect application launch with tag of ActivityManager in logs.

    in log you can find useful data.you can detect run packages.

    for example :

    06-06 16:09:06.007: I/ActivityManager(1663): Starting: Intent { act=android.intent.action.MAIN flg=0x10840000 cmp=com.android.phone/.InCallScreen } from pid -1
    

    it is com.android.phone package and InCallScreen starts for first page.

    you can check packages name and detect when your target application launched.

提交回复
热议问题