Я хочу поймать исключение, когда мой XML не анализируется.Поскольку я не имею никакого влияния на создаваемый XML, я не хочу ловить исключения, когда что-то идет не так (например, неправильные теги, странные знаки и т. Д.).
Я создал следующий код, новызывает сбой.Я добавил LogCat под кодом.Я не совсем понимаю, что LogCat говорит мне ... У кого-нибудь есть подсказка, чтобы помочь мне?Спасибо
private void getVacatures(){
functie = getIntent().getIntExtra("Functie", 0);
stat =getIntent().getIntExtra("Statuut", 0);
regio = getIntent().getIntExtra("Straal", 0);
opl = getIntent().getIntExtra("Opleiding", 0);
final AlertDialog.Builder builder = new AlertDialog.Builder(JobList.this);
try {
Log.e("in try", "try");
/* Create a URL we want to load some xml-data from. */
URL url = new URL("C:/Users/hannelore.deblau/Desktop/TESTXML.xml");
System.out.println("URL: "+ url);
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
vacatureWebservice vs = new vacatureWebservice();
xr.setContentHandler(vs);
/* Parse the xml-data from our URL. */
xr.parse(new InputSource(url.openStream()));
/* Parsing has finished. */
/* Our ExampleHandler now provides the parsed data to us. */
arrVacatures = vs.getVacatures();
} catch (Exception e) {
builder.setTitle(R.string.Fouttitel);
builder.setMessage(R.string.XMLfout);
builder.setCancelable(false);
builder.setPositiveButton(R.string.Ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
builder.create().show();
}
//runOnUiThread(returnRes);
}
В onCreate () я делаю это:
Handler handler = new Handler(); // This code is in the main UI activity class
handler.post(runnable= new Runnable(){
public void run(){
getVacatures();
runOnUiThread(returnRes);
}
});
Thread thread = new Thread(null, runnable, "MagentoBackground");
thread.start();
LogCat с ошибкой: http://pastebin.com/X5uk9cex