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) {              Log.e(LOG_TAG, ex.toString());          }          return null;      }

wifi获取公网IP测试通过

更多相关文章

  1. 获取当前locale
  2. Android(安卓)SAX解析xml为java
  3. android获取文件大小常用类
  4. 获取amlogic源码
  5. android获取app的版本信息
  6. android获取手机存储状态
  7. 在Android(安卓)emulator上测试NFC
  8. Android学习之SQLite数据库简单测试实例
  9. java 获取当前所有线程的两种方法 group和map

随机推荐

  1. android页面间传递对象
  2. Android电池管理
  3. Android定制出厂默认输入法
  4. Android学习
  5. Android(安卓)图片缩放与旋转
  6. android 如何在对话框中获取edittext中的
  7. This Android(安卓)SDK requires Android
  8. mapView 和textView布局
  9. 大话企业级android读书笔记(三)
  10. [Android(安卓)GMS 认证] CTS 问题列表之