我试图通过URL读取JSON数据,目前我在我的MainActivity类中的onCreate方法中获得了此代码段:
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权限,但它没有帮助。