android: get IP over WIFI on ICS
<p>I want to get the IP used by WIFI connection(not 3G). Does anybody know how to do it?
I used:</p>

<pre><code>public String getLocalIpAddress() {
try {
    for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
        NetworkInterface intf = en.nextElement();
        for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
            InetAddress inetAddress = enumIpAddr.nextElement();
            if (!inetAddress.isLoopbackAddress()) {
                return inetAddress.getHostAddress().toString();
            }
        }
    }
} catch (SocketException ex) {
    Log.e(LOG_TAG, ex.toString());
}
return null;
</code></pre>

<p>}</p>

<p>but it returns the 3G ip on ICS.</p>

<p>Thanks,</p>

<p>Alex</p>
