Android examples for Network:IP Address
get Loopback IP Address
//package com.java2s; import java.net.InetAddress; import java.net.UnknownHostException; import android.os.Build; public class Main { public static InetAddress getLoopbackAddress() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return InetAddress.getLoopbackAddress(); }//from w w w .ja v a 2 s. co m try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { // wtf... return null; } } }