编程语言
首页 > 编程语言> > 以编程方式在Android Nougat和O中获取设备mac地址

以编程方式在Android Nougat和O中获取设备mac地址

作者:互联网

我有一个应用程序,它需要设备mac地址.我在Marshmallow和下面很容易得到mac地址但是android nougat和O的问题.所以如何找到mac.

解决方法:

自6.0及更高版本更改:https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id

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.

7.0中的行为更改:

Device owners can access device identifiers. A Device owner can access
the Wi-Fi MAC address of a device, using
DevicePolicyManagewr.getWifiMacAddress(). If Wi-Fi has never been
enabled on the device, this method returns a value of null.

标签:android-8-0-oreo,android-settings,android-7-0-nougat,android
来源: https://codeday.me/bug/20191002/1843946.html