I want to run some code when an app is launched, so my broadcast receiver has to be notified when user open any app.
Is there any way to do it?
Probably you can have some trigger from a method like onCreate etc which would be the first method to be hit whenever your app is launched.
This is possible using accessibility services. An event AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED is recieved when the foreground activity is changed. The package name of the app in the foreground can be obtained from within the callback.
I have provided the code snippet in the answer to a similar question here.
How to monitoring app swaping in foreground?
The complete code for sample app to get the foreground process name is also available at https://github.com/abinpaul1/Android-Snippets/tree/master/GetForegroundService
No, sorry, there are no Intents broadcast when an application is started, nor when an activity is started.