-3
我试图读取JSON数据格式的URL,目前我在MainActivity类别得到了我的onCreate方法在这里面的代码片段:广东话从URL中读取JSON数据与Android
try {
URL url = new URL("https://bugzilla.mozilla.org/rest/bug/35");
try{
InputStream in = url.openStream();
JsonReader reader = new JsonReader(new InputStreamReader(in));
// more will be there...
} catch (IOException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
当我运行应用程序在虚拟设备上,它表示该程序已停止,甚至无法启动它。 也许我试图以错误的方式读取数据。 最重要的是,我想从URL读取JSON数据。我还向应用程序添加了INTERNET许可,但它没有帮助。
stacktrace。阅读。 – njzk2
你在UI线程上运行这个吗? – hoomi