Note that there are some explanatory texts on larger screens.

plurals
  1. POProgressDialog.dismiss() does not close in Async Class android
    primarykey
    data
    text
    <p>I have an inner class that downloads some images from the server. The problem is that the ProgressDialog does not dismiss() onPostExecute() method and don't understand why. I understand that the progress dialog should be shown onPreExecute() method, and the after the code from the doInBackground() finished , in the onPostExecute() method the dialog should be dismiss. Do you have any idea what i am doing wrong here? Thank you.</p> <pre><code> /** * Download images from server */ public class DownloadAsyncTask extends AsyncTask&lt;Void, Integer, Void&gt; { private ProgressDialog mDialog; // execution of result of Long time consuming operation protected void onPostExecute(Void result) { // progressDialog.show(); if (mDialog.isShowing()) { mDialog.dismiss(); } } // Things to be done before execution of long running operation. protected void onPreExecute() { mDialog = ProgressDialog .show(ImagesActivity.this, getString(R.string.pleasewait), getString(R.string.loading)); } // perform long running operation operation protected Void doInBackground(Void... params) { System.out.println("doInBackground loading.." + id); String tempPath = FileUtils.createTempFile(id); for (int i = 0; i &lt; imagePaths.size(); i++) { imagePaths.get(i).trim(); try { Bitmap imgTemp; imgTemp = FileUtils.downloadBitmapFromURL(id, imagePaths.get(i), tempPath); System.out.println("imgTemp: " + imgTemp); if (imgTemp != null) { // save image on sdcard. // compress it for performance Bitmap img = Bitmap.createScaledBitmap(imgTemp, 90, 80, true); imgTemp.recycle(); FileUtils.saveDataToFile(img, tempPath, imagePaths.get(i)); } else { continue; } } catch (IOException e) { e.printStackTrace(); mDialog.dismiss(); } } Looper.prepare(); mDialog.dismiss(); return null; } /* * Things to be done while execution of long running operation is in * progress. */ protected void onProgressUpdate(Integer... values) { if (mDialog.isShowing()) { mDialog.dismiss(); } } } </code></pre>
    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.
 

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