欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Android 获得手机ip地址,android获得手机ip,public Strin

来源: javaer 分享于  点击 14151 次 点评:202

Android 获得手机ip地址,android获得手机ip,public Strin


public String getLocalIpAddress() {          try {               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()) {                          return inetAddress.getHostAddress().toString();                      }                  }              }          } catch (SocketException ex) {         }          return null;      }  
相关栏目:

用户点评