BluetoothAdapter getAddress()返回02:00:00:00:00:00 [英] BluetoothAdapter getAddress() return 02:00:00:00:00:00

查看:751
本文介绍了BluetoothAdapter getAddress()返回02:00:00:00:00:00的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试返回设备的Bluetooth mac地址,但这不起作用,并返回以下地址:02:00:00:00:00:00.

-我正在使用API​​级别28
-我可以在android系统设置中获取蓝牙mac地址,但无法在我的应用中以编程方式获取.
-我可以通过编程方式从其他设备获取此设备的mac地址.

我了解的是访问地址mac仅适用于系统应用程序,但是如果这是事实,为什么其他设备获取我的mac地址而不是我!

I try to return the Bluetooth mac address of my device but this is not working and return this address : 02:00:00:00:00:00 .

-I'm using API Level 28
-I can get my Bluetooth mac address in my android system settings but not programmatically in my app.
-I can get the mac address of this device programmatically from other devices.

What I understand is that access to address mac is only for system applications ,but if It's true why other devices get my mac address and not me !

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
test.setText(adapter.getAdress());

我尝试了许多权限,但仍然存在相同的问题!

I try many permissions but still the same problem !

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />
<uses-permission android:name="android.permission.INTERNET" />

推荐答案

自Android 6起,棉花糖应用程序将无法再访问蓝牙硬件MAC地址.进行此更改是因为许多应用程序滥用了该地址来识别和跟踪智能手机.为避免现有应用程序损坏,getter方法仍然存在,但它返回一个虚拟地址.有关详细信息,请参见Android官方发行说明中的​​相应说明这里

Since Android 6, Marshmallow apps do not have access anymore to the bluetooth hardware MAC address. This change was made because the address was abused by many apps to identify and track smartphones. To avoid that existing apps are broken the getter method still exists but it returns a dummy address. For details see the corresponding note within Android's official release notes here

但是,MAC地址对其他设备的可见性如何?

But what about visibility of the MAC address to other devices?

  • 蓝牙低功耗(LE)不使用硬件MAC地址进行通信.它使用它的随机变体(请参见此处 有关详细信息).由于即使用户明确禁用了蓝牙,蓝牙LE也不会停止在后台扫描附近的设备,因此此功能 相当可观;-)

  • Bluetooth Low Energy (LE) does not use the hardware MAC address for communication. It uses a randomized variant of it (see here for details). Since Bluetooth LE does not stop scanning for nearby devices in background even when the user explicitly disables Bluetooth this feature is considerable ;-)

蓝牙经典不会随机化MAC地址.但是与蓝牙LE相比,用户可以至少轻松地完全禁用蓝牙.

Bluetooth classic does not randomize the MAC address. But in constrast to Bluetooth LE the user can at least easily and fully disable Bluetooth.

这篇关于BluetoothAdapter getAddress()返回02:00:00:00:00:00的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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