http://stackoverflow.com/questions/33159224/getting-mac-address-in-android-6-0
根據stackoverflow上的提問得知
public String ObtenMAC()
{
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
return(info.getMacAddress().toUpperCase());
}
並得到以下的說明結果
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.
根據
Android 6.0 Changes
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id
得到以下這些內容
Access to Hardware Identifier
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 theBluetoothAdapter.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:
Note: When a device running Android 6.0 (API level 23) initiates a background Wi-Fi or Bluetooth scan, the operation is visible to external devices as originating from a randomized MAC address.
至於解法,看未來有沒有機會再研究
沒有留言:
張貼留言