Detect When User Launches A New Application On An Android Device
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 I added this code inside
Solution 1:
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+.
Solution 2:
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.MAINflg=0x10840000cmp=com.android.phone/.InCallScreen } frompid-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.
Post a Comment for "Detect When User Launches A New Application On An Android Device"