不多说,直接上代码,解决双卡手机同时开通双卡时获取路由器mac地址时报错的问题 String connectedWifiMacAddress = ""; if (context != null) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); List<ScanResult> wifiList; if (wifiManager != null) { wifiList = wifiManager.getScanResults(); WifiInfo info = wifiManager.getConnectionInfo(); if (wifiList != null && info != null) { for (int i = 0; i < wifiList.size(); i++) { ScanResult result = wifiList.get(i); if (result != null &&(info.getBSSID()!=null)) { if (info.getBSSID().equals(result.BSSID)) { connectedWifiMacAddress = result.BSSID; } } } } } return connectedWifiMacAddress; } else { return ""; }