Solution 1 :
There are some broadcasts that require explicit registering in the system (Annotated with You can not receive this through components declared in manifests, only by explicitly registering for it with Context.registerReceiver().).
The most important ones for apps that run code after installing are:
ACTION_USER_PRESENT: Sent when the user is present after device wakes up (e.g when the keyguard is gone).
ACTION_SCREEN_ON: Broadcast Action: Sent when the device wakes up and becomes interactive.
ACTION_SCREEN_OFF: Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
ACTION_MY_PACKAGE_REPLACED: A new version of your application has been installed over an existing one. This is only sent to the application that was replaced. It does not contain any additional data; to receive it, just use an intent filter for this action.
ACTION_HEADSET_PLUG: Wired Headset plugged in or unplugged. Same as ACTION_HEADSET_PLUG, to be consulted for value and documentation.
ACTION_DATE_CHANGED: The date has changed.
Problem :
I would like to know if an Application such as whatsapp or youtube is opened by the user. Looking at the logcat, I can see that when the activity of the whatspp is opened – following
com.whatsapp.intent.action.CHATS
intent actions is opened. Am looking for a way to log this – so I can run an algorithm to suggest which page of the application will be opened at a given point of time
Comments
Comment posted by CommonsWare
“I would like to know if an Application such as whatsapp or youtube is opened by the user” — generally speaking, this is not supported on modern versions of Android, for privacy and security reasons. “Am looking for a way to log this” — that has not been possible for several years. You cannot spy on the details of the activities being started by the system, again for privacy and security reasons.
Comment posted by Balls
@CommonsWare Then how does apps like digital wellbeing is able to track the usage of these applications. Is there any specific API for that purpose
Comment posted by CommonsWare
“Then how does apps like digital wellbeing is able to track the usage of these applications” — that was written by Google. Google can use internal APIs that third-party apps are banned from using.
Comment posted by Balls
@CommonsWare Thanks that helps!
Comment posted by CommonsWare
Hi! Welcome to Stack Overflow! Please explain, in detail, what this has to do with the question.