Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You never called onProgressUpdate during your doInBackGround(...); Please note that running multipule instance of AsyncTask is a <a href="https://stackoverflow.com/questions/6645203/android-asynctask-avoid-multiple-instances-running">bad idea</a>. Here is what I suggest:</p> <p>if (isSyncSuccess) {</p> <pre><code> SetConstant.IMAGE_EXIST = 1; pDialog = new ProgressDialog(GalleryScreen.this); pDialog.setMessage("Downloading file. Please wait..."); pDialog.setIndeterminate(false); pDialog.setProgress(0); pDialog.setMax(contentId.length); pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pDialog.setCancelable(true); new DownloadFile().execute(); } } private class DownloadFiles extends AsyncTask&lt;String, Integer, String&gt; { @Override protected String doInBackground(String... sUrl){ Bitmap bm; InputStream in; if (contentId.length&gt;0){ for (int i=0;i&lt;contentId.length;i++){ if(helper.databaseChecking(useremail, contentId[i])){ contentdownload = i; SetConstant.CONTENT_ID = contentId[i]; String URL = SetConstant.URL_DOWNLOAD_CONTENT+contentId[i]; //YOUR INTRESTING LOOP HERE. publishProgress(30); //SOME INTRESTING NUMBER FOR PROGRESS UPDATE } } try{ in = new java.net.URL(sUrl[0]).openStream(); bm = BitmapFactory.decodeStream(new PatchInputStream(in)); File storage = new File(Environment.getExternalStorageDirectory() + File.separator + "/Image/"); Log.i(TAG,"storage:" +storage); Log.i(TAG,"storage:" +storage.getAbsolutePath()); if(!storage.exists()){ storage.mkdirs(); } String FileName = "/"+SetConstant.CONTENT_ID+".jpg"; FileOutputStream fos = new FileOutputStream(storage + FileName); bm.compress(Bitmap.CompressFormat.JPEG, 85, fos); String filepath = storage + FileName; File filecheck = new File (filepath); long fileSize = filecheck.length(); fos.flush(); fos.close(); } catch(IOException e1){ e1.printStackTrace(); } return null; } @Override protected void onPreExecute() { super.onPreExecute(); pDialog.show(); } @Override protected void onProgressUpdate(Integer... progress) { super.onProgressUpdate(progress); pDialog.setProgress(progress[0]); } protected void onPostExecute(String result) { super.onPostExecute(result); pDialog.dismiss(); } } </code></pre> <p>Of course this code don't run and you need to fix the scopes. but what I am trying to suggest is your loop should be in doInBackGround(...), you should only have 1 instance of AsyncTask at given time for this case, and call the onProgressUpdate();</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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