Getting MAC address in Android 6.0

后端 未结 10 2286
醉梦人生
醉梦人生 2020-11-27 04:48

I\'m developing an app that gets the MAC address of the device, but since Android 6.0 my code doesn\'t work, giving me an incorrect value.

Here\'s my code...

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 05:19

    Please refer to Android 6.0 Changes.

    To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.

    To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions.

提交回复
热议问题