I have an application-wide BroadcastReceiver
declared in the AndroidManifest.xml
. After a broadcast has been processed in the receiver, I want to start an activity to handle the event. There is two options:
a) if the target activity is running, simply update it;
b) if the target activity is not running, show notification to user, so he could click it and launch the activity.
But the receiver doesn't know if the activity is running or not. I was thinking of defining static variable running
inside the activity, which updates in onStart
and onPause
. But is this a reliable solution? I guess not.
What is the most appropriate way?