Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Communication and coordination between UI-thread and other thread
    primarykey
    data
    text
    <p>I'm using this AsyncTask for calling the skype page <a href="https://login.skype.com/json/validator?new_username=myusername" rel="nofollow">https://login.skype.com/json/validator?new_username=username</a> for understand if a certain skype contact already exsists.</p> <pre><code>public class SkypeValidateUserTask extends AsyncTask&lt;String, Void, String&gt;{ protected String doInBackground(String...urls){ String response = ""; for(String url:urls){ DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try{ HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s=""; while((s=buffer.readLine()) != null){ response+=s; } }catch(Exception ex){ ex.printStackTrace(); } } return response; } public void onPostExecute(String result){ String status=""; try{ JSONObject obj=new JSONObject(result); status=obj.getString("status"); }catch(Exception ex){ ex.printStackTrace(); } //Log.i("RISULTATO: ","STATO: "+status); } } </code></pre> <p>The main activity call this task for getting skype validation user result. The code is:</p> <pre><code>String skype = "name.surname.example"; if(!skype.equalsIgnoreCase("")){ // check if the skype contact exists SkypeValidateUserTask task = new SkypeValidateUserTask(); task.execute(new String[] {"https://login.skype.com/json/validator?new_username="+skype}); // here I need to obtain the result of the thread } </code></pre> <p>My problems are:</p> <ol> <li><p>I need to get the result of the task (the String <code>status</code>) in the main activity.</p></li> <li><p>After the <code>task.execute</code> call, the next code in main activity is executed without wait for result returned from asynctask.</p></li> </ol>
    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