I have an android APP which has some async threads running on an activity. In these threads an alert dialogue box is called under certain conditions.
However if I leave the activity and the alert dialogue tries to open, the APP will crash as the context is no longer valid for display. (NOTE: I don't want the dialogue box to display anyway when the user has moved on/back to another activity).
Is there a way for me to check if the current activity was the activity that called the async task?
This way I can have an
if(sameActivity){
alert.show();
}else{//do nothing}
Try this:
if (mContext instanceof MyActivity) {
where
mContext
- your current context,MyActivity
- your activity that called the async task