@Override
protected InputStream doInBackground(String... url){
try {
InputStream stream = downloadXml(url[0]);
new ParseXml(stream); //for testing porpuses: outputs ok to logcat
return stream;
} catch (IOException e) {
Log.d("dbg","exception");
e.printStackTrace();
return null;
}
}
@Override
protected void onPostExecute(InputStream result) {
if (result != null) {
new ParseXml(result); //crashes the app
}
Log.d("dbg","postexecute triggered ok");
}
Code is pretty self explanatory i think, i tried changing the passing type to just Object and type casted it where needed but it didn’t worked either.
Is there anything undocumented in sdk that i should know of ?
obviously, Crash.. You are doing lengthy (also may be network related) operation in MainUI Thread. as
onPostExecute()of AsyncTask runs on In MainUI Thread only. So always keep it indoInBackground().This code line
new ParseXml(result);should be indoInBackground()of AsyncTask.Update:
So complete the Parsing of XML in
doInBackground()and only pass the result inonPostExecute()if only you want to reflect the updation on Application UI.