Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't use <code>get()</code>. </p> <pre><code>data=new WebkioskExtractor().execute(username,password).get(); // Bad! :( data=new WebkioskExtractor().execute(username,password); // Good! :) </code></pre> <p>It blocks the <code>UI</code> which is why your <code>Button</code> remains pressed. This is also why your <code>ProgressBar</code> isn't showing up (it also runs on the <code>UI</code>). I assume you start your <code>ProgressBar</code> in <code>onPreExecute()</code> and <code>dismiss()</code> it in <code>onPostExecute()</code> of your <code>AsyncTask</code>. If not, this is what you should be doing. If everything else in your <code>AsyncTask</code> is set up correctly then removing <code>.get()</code> should fix your problem.</p> <p>Return your result from <code>doInBackground()</code> to <code>onPostExecute()</code> and this should give you what you want. You can also do whatever you need to on the <code>UI</code> from <code>onPostExecute()</code> or any other method of the <code>AsyncTask</code> besides <code>doInBackground()</code>.</p> <p><strong>ProgressBar</strong></p> <p>You don't need to set the <code>Visibility</code> on the <code>ProgressBar</code>. See this example:</p> <pre><code>public class GetUsersTask extends AsyncTask&lt;Void, Void, Void&gt; { ProgressDialog progress = ProgressDialog.show(LoginScreen.this, "Downloading Users", "Please wait while users are downloaded"); // you can create it here @Override protected void onPreExecute() { // show it here like so progress.setCancelable(false); progress.isIndeterminate(); progress.show(); } @Override protected void onPostExecute(Void result) { // and dismiss it here progress.dismiss(); } } @Override protected void onProgressUpdate(Void... values) { // can update the ProgressBar here if you need to } @Override protected Void doInBackground(Void... params) { ... } </code></pre> <h2> Using a callback </h2> <p>If you need to get a result from <code>AsyncTask</code> which <strong>is not an inner-class of your Activity</strong> then you can use an <code>interface</code> with a <code>callBack</code>. <a href="https://stackoverflow.com/questions/18517400/inner-class-can-access-but-not-update-values-asynctask/18517648#18517648">More about doing that in this answer</a></p> <p><a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow noreferrer">AsyncTask Docs</a></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