public class IPUtil {    public static String formatIpAddress(int ipAdress) {        return (ipAdress & 0xFF) + "." + ((ipAdress >> 8) & 0xFF) + "." + ((ipAdress >> 16) & 0xFF) + "."                + (ipAdress >> 24 & 0xFF);    }    //获取本地IP函数    public static String getLocalIPAddress() {        //获取wifi服务          WifiManager wifiManager = (WifiManager) App.getInstance().getApplicationContext()                .getSystemService(Context.WIFI_SERVICE);        //判断wifi是否开启          if (!wifiManager.isWifiEnabled()) {            wifiManager.setWifiEnabled(true);        }        WifiInfo wifiInfo = wifiManager.getConnectionInfo();        int ipAddress = wifiInfo.getIpAddress();        return formatIpAddress(ipAddress);    }}

更多相关文章

  1. Android中获取正在运行的应用程序-----ActivityManager.RunningA
  2. android 获取和设置屏幕亮度
  3. android jetpack Navigation 获取当前激活的fragment
  4. android解析httpresponce内容
  5. Android中通过按键旋转屏幕
  6. android findViewById
  7. Android(安卓)L下载
  8. 箭头函数的基础使用
  9. Python技巧匿名函数、回调函数和高阶函数

随机推荐

  1. Android:属性动画详解
  2. android自定义Actionbar遇到的一点问题【
  3. 工作笔记之编译android时切换JDK
  4. android ftp案例分析
  5. android中Activity实现再按一次退出
  6. 简析Android中LruCache缓存类
  7. 苹果为“制裁”亚马逊,禁止Kindle应用内购
  8. android退出activity提示再按一次返回键
  9. eclipse Missing Constraint: Bundle-Req
  10. Android验证码倒计时功能实现