Android obtains mobile IP address

From , 3 Years ago, written in Java, viewed 225 times.
URL https://pastebin.vip/view/5b5e6cc5
  1. public String getLocalIpAddress() {  
  2.  
  3.         try {  
  4.             for (Enumeration<NetworkInterface> en = NetworkInterface  
  5.                    .getNetworkInterfaces();  
  6.  
  7.             en.hasMoreElements();) {  
  8.  
  9.                NetworkInterface intf = en.nextElement();  
  10.  
  11.                 for (Enumeration<InetAddress> enumIpAddr = intf  
  12.                         .getInetAddresses();    
  13.                enumIpAddr.hasMoreElements();) {  
  14.                      InetAddress inetAddress = enumIpAddr.nextElement();  
  15.  
  16.                     if (!inetAddress.isLoopbackAddress()) {  
  17.  
  18.                         return inetAddress.getHostAddress().toString();  
  19.  
  20.                     }  
  21.  
  22.                 }  
  23.  
  24.             }  
  25.  
  26.         } catch (SocketException ex) {  
  27.        }  
  28.  
  29.         return null;  
  30.  
  31.     }  
  32. //java/5890

Reply to "Android obtains mobile IP address"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website