I\'ve seen many examples of how to do this, but I can\'t figure how to implement it in my code.
I am using this code.
I have updated the url, so it will receive
You can use AsycTask and update list ui on task finished within onPostExecute.
new AsyncTask() {
/**
* Before starting background do some work.
* */
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(String... params) {
// TODO fetch url data do bg process.
return null;
}
/**
* Update list ui after process finished.
*/
protected void onPostExecute(String result) {
// NO NEED to use activity.runOnUiThread(), code execute here under UI thread.
// Updating parsed JSON data into ListView
final List data = new Gson().fromJson(result);
// updating listview
((ListActivity) activity).updateUI(data);
}
};
}
Update
No need to use runOnUiThread inside onPostExecute, Because it's already called on and it's body executed under UIThread.