【发布时间】:2011-09-29 22:40:53
【问题描述】:
我在解析 XML 文件时遇到问题,我使用 newsRSS 解析器作为参考。但我在真实设备中遇到此错误。如何向用户显示错误消息,如警告并让他留在应用程序上没有崩溃?
这是执行连接和解析的代码的和平:
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);
}
}
如何在不崩溃或退出应用程序的情况下向用户发送警报来处理此错误?
感谢您的帮助:)
【问题讨论】:
-
您的日志消息不是很有帮助。它没有给出任何实际错误的指示。