Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to arrange long (time consuming) actions on Android?
    text
    copied!<p>For instance, we are in SomeActivity and the activity has a button that invokes moving files from one dir to another (let's call it job).</p> <p>On BlackBerry I would:</p> <ol> <li>push a non-cancellable popup (Dialog screen) saying "Please wait..."</li> <li>start a thread that fulfills the job</li> <li>on thread completion close the popup</li> </ol> <p>This approach 99.99% can guarantee that we stay on the same screen after the task is over, user just sees the popup and waits for job completion. Device rotation or whatever does not break the desired workflow.</p> <p>On Android things change. I know there's the AsyncTask that is probably provided to solve my case. There's even a good <a href="http://code.google.com/p/shelves/source/browse/trunk/Shelves/src/org/curiouscreature/android/shelves/activity/ShelvesActivity.java" rel="nofollow noreferrer">example</a> of how it should be used. But since there's no guarantee of how long an Activity instance will live the AsyncTask should be cancelled on onSaveInstanceState (and restarted on onRestoreInstanceState). This means using AsyncTask there's no guarantee we are able to fully fulfill the job once started. In some cases as sending an http post request for creating a user I would not want to get in "user already exists for this login" trouble on reruning the AsyncTask. This is possible since the AsyncTask can be interrupted while the request is already sent (and the server actually is doing its job - creating a new user), but the AsyncTask is canceled before we got the response.</p> <p>Is there any solution on Android to get the BB-like behaviour stated above?</p>
 

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