Android 6.0 移除了在使用Wi-Fi 和Bluetooth API 時直接通過程序訪問硬件設(shè)備標(biāo)識符。
以下方法會始終返回常量:02:00:00:00:00:00
1、WifiInfo.getMacAddress()
2未檩、BluetoothAdapter.getAddress()
通過Wi-Fi 和 Bluetooth掃描訪問外部設(shè)備的標(biāo)識符需要有位置權(quán)限
位置權(quán)限
1. ACCESS_FINE_LOCATION
2. ACCESS_COARSE_LOCATION
注意:因為上面兩個權(quán)限在同一權(quán)限組(permission_group)中,因此獲取其中一個由蘑,系統(tǒng)會自動獲取另一個權(quán)限部凑。
需要該權(quán)限的方法
1. WifiManager.getScanResults() // wifi 掃描
2. BluetoothDevice.ACTION_FOUND // 藍牙設(shè)備發(fā)現(xiàn)
3. BluetoothLeScanner.startScan() // 藍牙掃描
.