Note that there are some explanatory texts on larger screens.

plurals
  1. POAsyncTask not working with ProgressDialog in android
    primarykey
    data
    text
    <p>i am downloading data from website using <code>asynctask</code> and my code for async task is below</p> <pre><code>public class getSyncTaskInBackground extends AsyncTask&lt;Void, Void, Void&gt;{ @Override protected Void doInBackground(Void... params) { getSynchronizeTask(); return null; } @Override protected void onPostExecute(Void result) { if(progressDialog != null &amp;&amp; progressDialog.isShowing()) { progressDialog.dismiss(); } displaySynchronizetask(); super.onPostExecute(result); } @Override protected void onPreExecute() { progressDialog = ProgressDialog.show(synchronize.this, "Tasks are synchroning...", "Please wait..."); super.onPreExecute(); } @Override protected void onCancelled() { super.onCancelled(); if(progressDialog != null &amp;&amp; progressDialog.isShowing()) { progressDialog.dismiss(); } } } </code></pre> <p>this thread takes more time to complete task so if i want to cancel this thread in between of process then i had write this code of back button pressed or if progressbar is already dismiss then i want to close activity by calling <code>finish();</code> my code for back button is as below</p> <pre><code>@Override public void onBackPressed() { syncThread.cancel(true); //syncThread is the object of getSyncTaskInBackground if(progressDialog != null &amp;&amp; progressDialog.isShowing()) { progressDialog.dismiss(); } else { finish(); } } </code></pre> <p>Now when i pressed back button then the <code>progressdialog</code> is not dismiss is any mistake in mycode ? is any way to complete my need ? please help me</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. 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