国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android編程實現獲取當前連接wifi名字的方法

2020-04-11 11:15:42
字體:
來源:轉載
供稿:網友

本文實例講述了Android編程實現獲取當前連接wifi名字的方法。分享給大家供大家參考,具體如下:

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);

希望本文所述對大家Android程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉木萨尔县| 中阳县| 临江市| 无棣县| 多伦县| 白玉县| 林甸县| 古田县| 库伦旗| 荃湾区| 惠水县| 镇宁| 怀宁县| 南木林县| 长海县| 上饶市| 昌吉市| 昌乐县| 三门峡市| 紫金县| 忻城县| 化州市| 平舆县| 马龙县| 永和县| 阳泉市| 华蓥市| 太谷县| 长沙县| 金平| 巴彦县| 隆安县| 察隅县| 盖州市| 湛江市| 洛宁县| 翁牛特旗| 三都| 安乡县| 关岭| 呼和浩特市|