In my case the issue is occurred because of am trying to open/show dialog box in onPostExecute
AsyncTask
However its an wrong method of showing dialog
or Ui changes in onPostExecute
.
For that, we need to check the activity is in active Eg : !isFinishing()
, if the activity is not finished then only able to show our dialog box or ui change.
@Override
protected void onPostExecute(String response_str) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (!((Activity) mContext).isFinishing()) {
try {
ShowAgilDialog();
} catch (WindowManager.BadTokenException e) {
Log.e("WindowManagerBad ", e.toString());
}
}
}
});
}