When I call my AsyncTask, doInBackground is run but onPostExecute is never called afterwards. Eclipse is not complaining about @Override
s or any of the parameters in the AsyncTask, so I'm not sure what the issue is. Can anyone tell me what the problem is?
Calling AsyncTask:
new AsyncDataFetcher(this).execute(productInfoUrls);
productInfoUrls
is a list of urls.
AsyncTask:
private static class AsyncDataFetcher extends AsyncTask<List<String>, Void, List<JSONObject>> {
Context context;
public AsyncDataFetcher(Context context) {
this.context = context;
}
@Override
protected List<JSONObject> doInBackground(List<String>... urls) {
List<JSONObject> jsonList = new ArrayList<JSONObject>();
JSONParser json_parse = new JSONParser();
for (int i = 0; i < urls[0].size(); i ++) {
jsonList.add(json_parse.getJSONFromUrl(urls[0].get(i)));
}
return jsonList;
}
@Override
protected void onPostExecute(List<JSONObject> jsonList) {
if(jsonList != null){
productInfoParser.Parse(jsonList);
loaded = true;
}
}
}
Everything looks appropriate in your async task structure, but what you are doing in doInBackground
could take forever! I suspect that your app is starting the doInBackground
and never finishing it.
I would add some debug logs to see how the json getting is progressing.
@Override
protected List<JSONObject> doInBackground(List<String>... urls) {
List<JSONObject> jsonList = new ArrayList<JSONObject>();
JSONParser json_parse = new JSONParser();
for (int i = 0; i < urls[0].size(); i ++) {
jsonList.add(json_parse.getJSONFromUrl(urls[0].get(i)));
Log.d(TAG, "added " + i);
}
Log.d(TAG, "returning jsonList");
return jsonList;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With