我有一个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");
}
}
日志说:
最佳答案
您的例外似乎没有消息。因此它向记录器发送null,而记录器不喜欢它。您可以改为发送e.toString()。
关于java - Android:AsyncTask强制关闭,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6172855/