WifiManager wifiMgr = (WifiManager) mActivity.getSystemService(Context.WIFI_SERVICE);        int wifiState = wifiMgr.getWifiState();        WifiInfo info = wifiMgr.getConnectionInfo();        String wifiId = info != null ? info.getSSID() : null;

public static InetAddress getWifiIp() {        Context myContext = Globals.getContext();        if (myContext == null) {            throw new NullPointerException("Global context is null");        }        WifiManager wifiMgr = (WifiManager) myContext.getSystemService(Context.WIFI_SERVICE);        if (isWifiEnabled()) {            int ipAsInt = wifiMgr.getConnectionInfo().getIpAddress();            if (ipAsInt == 0) {                return null;            } else {                return Util.intToInet(ipAsInt);            }        } else {            return null;        }    }

  // 取得wifi的ip地址

  InetAddress address = FTPServerService.getWifiIp();
  address.getHostAddress();
  

public static boolean isWifiEnabled() {        Context myContext = Globals.getContext();        if (myContext == null) {            throw new NullPointerException("Global context is null");        }        WifiManager wifiMgr = (WifiManager) myContext.getSystemService(Context.WIFI_SERVICE);        if (wifiMgr.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {            ConnectivityManager connManager = (ConnectivityManager) myContext                    .getSystemService(Context.CONNECTIVITY_SERVICE);            NetworkInfo wifiInfo = connManager                    .getNetworkInfo(ConnectivityManager.TYPE_WIFI);            return wifiInfo.isConnected();        } else {            return false;        }    }

// 打开wifi设置的页面

Intent intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);startActivity(intent);

更多相关文章

  1. Android(安卓)布局学习
  2. Android(安卓)- 禁止Gridview滚动
  3. android时间控件DatePicker使用实例
  4. android 实现圆形进度条
  5. RecyclerView竖直和水平的瀑布流布局
  6. Android通知工具类,含8.0通知适配,打开通知设置页面适配
  7. Android(安卓)布局
  8. android之WebView的使用
  9. android view画图笔记-1

随机推荐

  1. android 百度地图SDK 获得详细路线信息
  2. Android sd卡log日志
  3. 我是如何自学Android,资料分享(转)
  4. android避免decodeResource图片时占用太
  5. Android(安卓)SVG矢量图/矢量动画、Vecto
  6. Flutter 与 Android 相互调用、传递参数
  7. ETC1压缩纹理格式详解
  8. android隐藏以及显示软键盘
  9. android个人错误,持续更新
  10. 开发人员的怨念:Android开发应用像噩梦