2011-05-30 186 views
0

我有一個解析xml文件的asynctask。我將它的值存儲到主要活動的變量中。當我運行下面的代碼時,它強制關閉。Android:AsyncTask強制關閉

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的說:

enter image description here

回答

1

你的例外似乎並不有一個消息。所以它發送空記錄器和記錄器不喜歡它。您可以發送e.toString()。