Trigger broadcast receiver only if my activity is in memory, else it should not get triggered, how to do it?
Send broadcast only when your activity is alive.
Register a dynamic receiver in that Activity.
Register a static receiver in manifest file
It is not possible to achieve
If you want to trigger broadcast receiver as long as activity is in memory, then go for dynamic receiver which gets registered only when activity comes into memory. and unregister it before killing your activity.
Back To Top