Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.net.SocketException: Address family not supported by protocol in android emulator
    primarykey
    data
    text
    <p>I am trying to run simple application to access internet from android emulator and here is my code. I am behind proxy and configured proxy settings in emulator by"...Wireless Networks -> APN -> ..." . But internet is working from browser and not from application. </p> <pre><code> HttpURLConnection connection = null; String URLName = "http://www.google.com"; try { URL u = new URL(URLName); connection = (HttpURLConnection) u.openConnection(); connection.setRequestMethod("HEAD"); int code = connection.getResponseCode(); Log.d(TAG1, " " + code); // You can determine on HTTP return code received. 200 is success. } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.d(TAG1, e.toString()); } finally { if (connection != null) { connection.disconnect(); } } </code></pre> <p>The part of error log in Logcat is as follows:</p> <pre><code>01-11 01:01:26.308: DEBUG/SntpClient(72): request time failed: java.net.SocketException: Address family not supported by protocol 01-11 01:02:39.909: WARN/System.err(422): java.net.SocketException: The operation timed out </code></pre> <p>I tried the following options after searching in forum but none of them seems working:</p> <ol> <li><p>In android launch options I used -http-proxy server:port -dns-server server</p></li> <li><p>I have included internet permissions in manifest file</p> <p>uses-permission android:name="android.permission.INTERNET" </p> <pre><code>uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" </code></pre></li> <li><p>Set the system properties to use ipv4 stack after someone suggested</p> <pre><code> java.lang.System.setProperty("java.net.preferIPv4Stack", "true"); java.lang.System.setProperty("java.net.preferIPv6Addresses", "false"); </code></pre></li> </ol> <p>I am working on Android 2.2 and windows vista, can you please help me here...</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.
 

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