我有一个asynctask从网络解析xml文件。我将其值存储到主要活动的变量中。当我运行以下代码时,它强制关闭。
private class parseXMLAsync extends AsyncTask <String, String, String>{
protected void onPreExecute(){
super.onPreExecute();
showDialog(PARSE_XML);
}
@Override
protected String doInBackground(String... strings) {
try{
Engagia.this.url.openConnection();
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
ExampleHandler myExampleHandler = new ExampleHandler();
xr.setContentHandler(myExampleHandler);
xr.parse(new InputSource(Engagia.this.url.openStream()));
List<ParsedExampleDataSet> parsedExampleDataSet = myExampleHandler.getParsedData();
Iterator i;
i = parsedExampleDataSet.iterator();
ParsedExampleDataSet dataItem;
while(i.hasNext()){
dataItem = (ParsedExampleDataSet) i.next();
String folder = dataItem.getParentTag();
if( folder == "Videos" ){
MainAct.this.videoNames[MainAct.this.videoCount] = dataItem.getName();
MainAct.this.videoCount++;
}
}
}catch(Exception e){
Log.e(LOG_TAG, e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(String lenghtOfFile) {
if( mProgressDialog.isShowing() ){
dismissDialog(PARSE_XML);
}
String str_contents = null;
PopIt("Parsing Done", "STR CONTENTS >> " + str_contents, "Denied");
}
}
logcat说:
答案 0 :(得分:1)
您的例外似乎没有消息。因此它向logger发送null并且logger不喜欢它。您可以改为发送e.toString()。