This normally happens when the Activity
might have finished or in pause state before the AsyncTask
is complete. onPause
of the Activity
set the dialog to null or dismiss it
@Override
protected void onPostExecute(Void result) {
if(!isPaused && dialog.isShowing()){
dialog.dismiss(); <-------- HERE IT HAPPENS
}
}
boolean isPaused;
@Override
protected void onPause() {
super.onPause();
isPaused = true;
}
@Override
protected void onResume() {
super.onResume();
isPaused = false;
if(dialog.isShowing() && (asyncFinishedCheck)){
//Dismiss code goes here
}
}