获得棉花糖蓝牙本地MAC地址 [英] Get Bluetooth local mac address in Marshmallow
问题描述
pre棉花糖我的应用程序将获得它通过 BluetoothAdapter.getDefaultAdapter()的getAddress()。
Pre Marshmallow my app would obtain it's device MAC address via BluetoothAdapter.getDefaultAdapter().getAddress().
现在用棉花糖Android是返回 02:00:00:00:00:00
。
Now with Marshmallow Android is returning 02:00:00:00:00:00
.
我看到一些链接(抱歉,不知道现在在哪里),该说你需要添加额外的许可
I saw some link(sorry not sure where now) that said you need to add the additional permission
<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS"/>
要能够得到它。但是它不是为我工作。
to be able to get it. However it isn't working for me.
时那里得到的mac地址需要一些额外的许可?
Is there some additional permission needed to get the mac address?
我不知道这是有关在这里,但该清单还包括
I am not sure it is pertinent here but the manifest also includes
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
那么,有没有办法让本地蓝牙MAC地址?
So is there a way to get the local bluetooth mac address?
推荐答案
zmarties是正确的,但你仍然可以通过反射或Settings.Secure获取MAC地址:
zmarties is right but you can still get the mac address via reflection or Settings.Secure:
String macAddress = android.provider.Settings.Secure.getString(context.getContentResolver(), "bluetooth_address");
这篇关于获得棉花糖蓝牙本地MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!