android - AsyncTask while screen locked or overlapped by other app -


Text after "

There is a piece page with "send" action. Button will launch AsyncTask.execute which will do some network works in doInBackground, then success will appear toast message and remove yourself in onPostExecute

How to avoid " IllegalStateException: Action can not be done after OnSaveInstanceState "when inPostExecute happened when the screen is already locked in the moment?

It is possible () waiting for tasks like popBackStack or onBackPressed () when they can not be turned off in the state state

connected with screen rotation or other configuration No change in PS current question events

Code example (AsyncTask from piece):.

  SubmitTask asyncTask the private last class extends, zero zero, string & gt; {@Override protected string doInBackground (zero ... vacancies) {// ...} @Override protected void onPostExecute (string error) {if (mistake = null!) {Toast .makeText (parentActivity, "error occurs) Ed : "+ Err, toast.LENGTH_SHORT) .show (); } Else {Toast.makeText (parentActivity, "Saved", Toast.LENGTH_SHORT) .show (); ParentActivity.getSupportFragmentManager (). PopBackStack (); // & lt; & Lt; ---- Exceptions crashed here}}  

The simplest thing is < / P>

  try {....} hold (IllegalStateException e) {}  

Comments