在 Marshmallow 中获取蓝牙本地 mac 地址 [英] Get Bluetooth local mac address in Marshmallow

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

问题描述

Pre Marshmallow 我的应用程序将通过 BluetoothAdapter.getDefaultAdapter().getAddress().

Pre Marshmallow my app would obtain it's device MAC address via BluetoothAdapter.getDefaultAdapter().getAddress().

现在有了 Marshmallow,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?

推荐答案

事实证明,我最终没有从 Android 获取 MAC 地址.蓝牙设备最终提供了 Android 设备的 MAC 地址,该地址被存储起来,然后在需要时使用.是的,这看起来有点奇怪,但在我参与的项目中,蓝牙设备软件也在开发中,结果证明这是处理这种情况的最佳方式.

As it turns out, I ended up not getting the MAC address from Android. The bluetooth device ended up providing the Android device MAC address, which was stored and then used when needed. Yeah it seems a little funky but on the project I was on, the bluetooth device software was also being developed and this turned out to be the best way to deal with the situation.

这篇关于在 Marshmallow 中获取蓝牙本地 mac 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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