/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
try { for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { if (!inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress().toString(); } } } Log.e(LOG_TAG, ex.toString()); } return null; }