Here you can find the source of getLocalIpAddress()
public static InetAddress getLocalIpAddress()
//package com.java2s; import android.util.Log; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; public class Main { public static InetAddress getLocalIpAddress() { try {/*from w w w .java 2s .c o m*/ for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf .getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { Log.i("IP", inetAddress.getHostAddress()); return inetAddress; } } } } catch (SocketException ex) { Log.e("IPNo", ex.toString()); } return null; } }