【发布时间】:2012-09-22 00:20:14
【问题描述】:
我的应用程序在尝试获取远程 txt 文件时崩溃。 即使只是尝试解析一个 url 它也会崩溃。 已设置互联网权限,并且设备/虚拟机已连接到互联网。
LogCat:
代码sn-p:
try {
// the following line is enough to crash the app
URL url = new URL("http://www.i.am/not/going/to/show/you/this.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
while ((line = in.readLine()) != null) {
//get lines
}
in.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
我不明白我做错了什么。提前感谢您的帮助。
//编辑:添加log cat sn -p
【问题讨论】:
-
任何时候发生崩溃,重要的信息都会记录在LogCat中。请发布您的相关 logcat 异常。
-
添加了日志猫截图的链接
-
@user1687295 您是在哪个设备 API 版本上测试此应用程序?
-
它在 api 级别 10 (android 2.3.3) 上运行
标签: android text-files