我有办法获取wifi列表中每个wifi的mac地址吗?
我目前的代码如下:
wifiList = mainWifi.getScanResults();
JSONArray requestData = new JSONArray();
for (int i = 0; i < wifiList.size(); i++) {
JSONObject wifiNetwork = new JSONObject();
try {
wifiNetwork.put("MSource", "WIFI");
wifiNetwork.put("MName", (wifiList.get(i)).SSID);
// this way I am getting mac address of current device.
wifiNetwork.put("MAddress", mainWifi.getConnectionInfo().getMacAddress());
wifiNetwork.put("MCreatedOn", "Some date time");
} catch (JSONException e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
你应该使用来自getConnectionInfo()的getBSSID(),而不是getMacAddress()(返回当前连接的mac)。