String ip = "" ; String remote = mstr_remote ; try { for (Enumeration en = NetworkInterface. getNetworkInterfaces (); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { if (inetAddress instanceof Inet4Address) { ip = inetAddress.getHostAddress().toString(); Log. d ( TAG , "inetAddress host : " + ip); } } } } } catch (SocketException ex) { Log. e ( TAG , ex.toString()); }