获取MAC地址的Andr​​oid 6.0 [英] Getting MAC address in Android 6.0

查看:1438
本文介绍了获取MAC地址的Andr​​oid 6.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,获得设备的MAC地址,但由于Android 6.0我的code不工作,给我一个不正确的值。

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.

下面是我的code ...

Here's my code...

    public String ObtenMAC()
{
    WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = manager.getConnectionInfo();

    return(info.getMacAddress().toUpperCase());
}

而不是真正的MAC地址,则返回一个奇怪的code:02:00:00:00:00:00。

Instead of the real MAC address, it returns an strange code: "02:00:00:00:00:00".

任何人可以帮助我解决这个问题?

Can anybody help me to solve it?.

先谢谢了。

推荐答案

请参阅<一个href=\"https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id\">Android 6.0更改。

要为用户提供更高的数据保护,在此版本中开始,Android的删除程序访问设备的本地硬件标识符使用的Wi-Fi和蓝牙API的应用程序。所述WifiInfo.getMacAddress()和BluetoothAdapter.getAddress()方法现在返回02的恒定值:00:00:00:00:00

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.

要通过蓝牙和Wi-Fi扫描访问外部附近设备的硬件标识,您的应用程序现在必须有ACCESS_FINE_LOCATION或ACCESS_COARSE_LOCATION权限。

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.

这篇关于获取MAC地址的Andr​​oid 6.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆