Note that there are some explanatory texts on larger screens.

plurals
  1. POUnknownHostException with HTTPConnection in Android
    primarykey
    data
    text
    <p>An <code>UnknownHostException</code> arises when I attempt to execute the following code...</p> <pre><code>String line; String url = "http://mywebsite.com"; URL theURL = new URL(url); HttpURLConnection conn = (HttpURLConnection) theURL.openConnection(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); line = rd.readLine(); conn.disconnect(); </code></pre> <p>I have followed suggestions from former posts to <strong>ensure that the Internet Permission Tag appears</strong> properly in the manifest. I also made sure that my Android has WIFI access, and that the website I am attempting to use is correct. This usually appeared to be a popular resource on StackOverflow: <a href="http://guerrarj.hubpages.com/hub/Tips-to-solve-the-UnknownHostException-on-Android" rel="nofollow">http://guerrarj.hubpages.com/hub/Tips-to-solve-the-UnknownHostException-on-Android</a></p> <p>The stack trace is...</p> <pre><code>java.net.UnknownHostException: the_website.com at java.net.InetAddress.lookupHostByName(InetAddress.java:512) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:300) at java.net.InetAddress.getAllByName(InetAddress.java:259) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.&lt;init&gt;(HttpConnection.java:69) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.&lt;init&gt;(HttpConnection.java:48) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512) at com.example.privacyapp.MainActivity.scrapWeb(MainActivity.java:127) at com.example.privacyapp.MainActivity.checkLocation(MainActivity.java:148) at com.example.privacyapp.MainActivity$1.onLocationChanged(MainActivity.java:93) at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:227) at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:160) at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:176) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:4263) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p><strong>Update:</strong> It appeared that my WIFI connection was faulty. Without a connection, the UnknownHostException arises. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload