Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you're using an AsyncTask you have the option to use onProgressUpdate(Progress...), invoked on the UI thread after a call to publishProgress(Progress...).</p> <p>E.g.</p> <pre><code> private class DownloadFilesTask extends AsyncTask&lt;File, Integer, Long&gt; { protected Long doInBackground(File... file) { // This will call onProgressUpdate publishProgress((int) ((i / (float) count) * 100)); } // this will be called on the UI thread protected void onProgressUpdate(Integer... progress) { setProgressPercent(progress[0]); } protected void onPostExecute(Long result) { showDialog("Downloaded " + result + " bytes"); } } </code></pre> <p>If you're not using an AsyncTask you can create a Handler and post messages to the UI thread that way.</p> <p>But as you mention file downloads some things to consider (from Android docs):-</p> <ul> <li>The device might not have enough space for the expansion files, so you should check before beginning the download and warn the user if there's not enough space.</li> <li>File downloads should occur in a background service in order to avoid blocking the user interaction and allow the user to leave your app while the download completes.</li> <li>A variety of errors might occur during the request and download that you must gracefully handle.</li> <li>Network connectivity can change during the download, so you should handle such changes and if interrupted, resume the download when possible.</li> <li>While the download occurs in the background, you should provide a notification that indicates the download progress, notifies the user when it's done, and takes the user back to your application when selected.</li> </ul> <p>Luckily all of the above are covered in a library from Google, which provides a download with notifications of progress (even if you quit your app). You can use it, or modify the source to your own needs. More info here</p> <p><a href="http://developer.android.com/google/play/expansion-files.html#AboutLibraries" rel="nofollow">http://developer.android.com/google/play/expansion-files.html#AboutLibraries</a></p>
    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. VO
      singulars
      1. This table or related slice is empty.
 

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