Asynctask And Json, Onsuccess Doesn't Return Anything
I'm here with another question. I post you the code from my AsyncTask function to get values from a JSONObject (webservice). My problem is that I have a List and I fill this list w
Solution 1:
if you are using loopj android-async-http then no need to use AsyncTask
for getting data from server doInBackground
and updating UI in onPostExecute because onSuccess
method always execute on UI Thread after background computation. just do it without AsyncTask as :
AsyncHttpClient client = newAsyncHttpClient();
client.get("Pass Url Here", null, newJsonHttpResponseHandler() {
@OverridepublicvoidonSuccess(JSONObject data) {
// update your ListView here
}
@OverridepublicvoidonFailure(Throwable arg0, JSONObject arg1) {
// TODO Auto-generated method stubsuper.onFailure(arg0, arg1);
}
});
Solution 2:
onPostExecuted
is called when the doInBackground
runs out its execution. If the get method of AsyncHttpClient
is not a blocking method, onPostExecuted
is called before onSuccess
parses the result
Post a Comment for "Asynctask And Json, Onsuccess Doesn't Return Anything"