Note that there are some explanatory texts on larger screens.

plurals
  1. POProgressDialog not shown when AsyncTask.get() called
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/5583137/asynctask-block-ui-threat-and-show-progressbar-with-delay">AsyncTask block UI threat and show progressbar with delay</a> </p> </blockquote> <p>I want to show a progressDialog while retrieving JSON from any server. So I had used AsyncTask as a solution (not sure any different way out). </p> <p>Everything is fine, the ProgressDialog works properly until I call .get() method using AsyncTask instance. I suppose it's blocking UI somehow. Here is my AsyncTask:</p> <pre class="lang-java prettyprint-override"><code>public class myAsync extends AsyncTask&lt;String, String, List&gt; { String message; // for dialog message ProgressDialog progress; Intent myIntent; Context ctx; public myAsync(String message, Context ctx) { this.message = message; this.ctx = ctx; progress = new ProgressDialog(ctx); } @Override protected void onPreExecute() { progress.setMessage(message); progress.setIndeterminate(true); progress.setCancelable(false); progress.show(); } @Override protected List doInBackground(String... params) { //returns any list after the task return anyList; } @Override protected void onPostExecute(List result) { if(progress.isShowing()) progress.dismiss(); } } </code></pre> <p>And here is myActivity which is calls AsyncTask:</p> <pre class="lang-java prettyprint-override"><code>myAsync asyncTask = new myAsync("Loading...", this); asyncTask.execute("Any string", "Other string"); asyncTask.get(); // If I comment out this line, ProgressDialog works </code></pre> <p>After execute, when I tried to log the result from doInBackground and onPostExecute both there is no problem. But if I want to get with .get() the result ProgressDialog is not shown or shown so little time (maybe 0.2 seconds)</p> <p>What's the problem? </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