Is there any simple way of determining whether or not a certain activity is active?
I want to do certain things depending on which activity is active.
eg:
if(activityrunning == activity1)
//do this
else if (activityrunning == activity2)
//do something else
You can use a
staticvariable within the activity.The only gotcha is that if you use it in two activities that link to each other then
onStopon the first is sometimes called afteronStartin second. So both might be true briefly.Depending on what you are trying to do (update the current activity from a service?). You could just register a static listener in the service in your activity
onStartmethod then the correct listener will be available when your service wants to update the UI.