I am using ksoap2-Android for making and parsing my requests. How ever if i want to use it i have to do it asynchronous. So i choose to create a new Thread for that.
It looks something like that, i don’t post all my logic request and parsing because int this case it isn’t important.
new Thread(new Runnable() {
public void run() {
String answer = WebServiceRequests.About();
try{
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}).start();
So i get request in answer string, but now how to update my GUI ? When i try i get exception that i can’t update in that thread.
Please post your solutions to this. If you used Handler or AsyncTask or even make to work with my example.
Thanks.
AsnycTask is always the first recommandation, If you haven’t done this before, read this official dev guide, sample code:
}
To start your AsyncTask:
onPostExecute method is guaranteed to be called on UI thread at some point in the future, as soon as the background thread (AKA. doInBackground) is finished. The underlying framework handle all dirty work for us.
Hope this helps.