1、获取移动网络ip



2、代码

    public String getLocalIpAddress() {         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() && inetAddress instanceof Inet4Address) {                      return inetAddress.getHostAddress().toString();                      }                 }             }         } catch (SocketException ex) {         Log.e("get IpAddress fail", ex.toString());         return "";       }         return "";     } 


加上权限

&l

更多相关文章

  1. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像
  2. Android屏幕分辨率正确获取及PX,DPI,DP,SP等的对应关系
  3. android 获取唯一标识
  4. android拍照与读取相册
  5. Android(安卓)给 app默认权限(不弹窗申请权限)
  6. Android(安卓)热点开关状态的判断和获取热点ssid
  7. Android软键盘适配问题
  8. AIR Native Extension的使用(Android)一 : 打包ane
  9. android之BitMap

随机推荐

  1. MySQL中的行级锁定示例详解
  2. Android(安卓)mk编译OkHttp3
  3. Ubuntu下 下载Android(安卓)源码(来自官网
  4. android 读取指定路径数据库文件
  5. Android(安卓)transformClassesWithDexFo
  6. Android(安卓)之安装APK
  7. 【问题】Android(安卓)Studio3.1.2 Rejec
  8. Android(安卓)TV开发中所有的遥控器按键
  9. Android(安卓)Jetpack Components of Vie
  10. android Gallery3D效果