我在解析XML文件時遇到了問題,我使用newsRSS解析器作爲參考。但是我在實際的device.how中收到此錯誤顯示一條錯誤消息,如警告用戶,讓他留在應用程序沒有崩潰?java.lang.RuntimeException:java.net.UnknownHostException:主機未解決:
這是做連接和解析代碼的和平:
protected Config_Parser(String feedUrlString,Context context){
this.context = context;
try {
this.feedUrl = new URL(feedUrlString);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
protected InputStream getInputStream() {
try {
return feedUrl.openConnection().getInputStream();
} catch (IOException e) {
Log.e("Error", "error happned");
return null;
//throw new RuntimeException(e);
}
}
我怎麼可以處理這個錯誤與發送警報給用戶沒有崩潰或退出應用程序?
感謝您的幫助:)
您的日誌消息不是很有幫助。它沒有給出任何錯誤實際上的跡象。 – unholysampler