美文网首页
Android 6.0 Wi-Fi 和 Bluetooth扫描需

Android 6.0 Wi-Fi 和 Bluetooth扫描需

作者: 王世军Steven | 来源:发表于2016-08-05 12:23 被阅读204次

    Android 6.0 移除了在使用Wi-Fi 和Bluetooth API 时直接通过程序访问硬件设备标识符。
    以下方法会始终返回常量:02:00:00:00:00:00
    1、WifiInfo.getMacAddress()
    2、BluetoothAdapter.getAddress()

    通过Wi-Fi 和 Bluetooth扫描访问外部设备的标识符需要有位置权限
    位置权限
    1. ACCESS_FINE_LOCATION
    2. ACCESS_COARSE_LOCATION
    注意:因为上面两个权限在同一权限组(permission_group)中,因此获取其中一个,系统会自动获取另一个权限。

    需要该权限的方法

    1. WifiManager.getScanResults() // wifi 扫描
    2. BluetoothDevice.ACTION_FOUND // 蓝牙设备发现
    3. BluetoothLeScanner.startScan() // 蓝牙扫描
    

    .

    相关文章

      网友评论

          本文标题:Android 6.0 Wi-Fi 和 Bluetooth扫描需

          本文链接:https://www.haomeiwen.com/subject/ebmhsttx.html