在Android中访问Earthquake API。的UnknownHostException

时间:2012-03-22 07:58:07

标签: java android http url

我只是想尝试访问Earthquake API而且我遇到了这个错误。

03-22 00:55:27.805: W/System.err(1044): java.net.UnknownHostException: Unable to resolve host "earthquake.usgs.gov": No address associated with hostname 03-22 00:55:27.815: W/System.err(1044): at java.net.InetAddress.lookupHostByName(InetAddress.java:426) 03-22 00:55:27.815: W/System.err(1044): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242) 03-22 00:55:27.815: W/System.err(1044): at java.net.InetAddress.getAllByName(InetAddress.java:220)

1 个答案:

答案 0 :(得分:6)

您是否在其AndroidManifest.xml文件中提供了应用程序the INTERNET permission

你应该有一行如下:

<uses-permission android:name="android.permission.INTERNET"/>