获得棉花糖蓝牙本地MAC地址 [英] Get Bluetooth local mac address in Marshmallow

查看:1556
本文介绍了获得棉花糖蓝牙本地MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

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