Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI have a working approach for onStop() and onStart(). Where the problem comes in is with onPause(), ie. my Activity is no longer visible. In the case of a pause, the dialog remains open and the AsyncTask continues executing. Once the task completes, it attempts to close a ProgressDialog using Activity.dismissDialog(), which works fine even while paused. Then it tries to dismiss a DialogFragment (ACP version), by calling DialogFragment.dismiss(). This results in an InvalidStateException.
      singulars
    2. COI'm afraid you may need to rethink your design. The simplest way to do what you want with the leat work may be to just close the dialog in the onPause(). You could also try to cancel the AsyncTask in the onPause, but that may depend on what the AsyncTask is doing. the AsyncTask class does have a cancel method, but that doesn't actually kill the spawned thread, it simply sets a flag and your code inside the AsyncTask must somehow deal with it. Some IO tasks, such as network traffic, can be particularly tricky to cancel or abort. In which case, trying to cancel the AsyncTask could be a problem.
      singulars
    3. COI would also suggest you consider a service. The service could then broadcast the results to your activity. With this model no attempts to access the dialog would be made outside of your activity. To be honest, I sometimes wish they never made AsyncTask for reasons such as this, it actually makes dealing with the edge cases harder.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload