gpt4 book ai didi

java - 每个蓝牙设备都有自己唯一的 MAC 地址吗?我们如何在应用程序中访问它?

转载 作者:行者123 更新时间:2023-11-30 20:25:18 25 4
gpt4 key购买 nike

据我了解,从离开工厂大门的那一刻起,所有蓝牙设备都有一个与它们相关联的通用唯一标识符。例如,同样来自您的链接“如果设备是可发现的,它将通过共享一些信息(例如设备名称、类别及其唯一的 MAC 地址)来响应发现请求。”我对 MAC 地址明确感兴趣,并且它最好是普遍唯一的。如果我的假设是错误的,那么知道这一点也是一件好事。

最佳答案

要获取蓝牙 MAC 地址,请使用 BluetoothAdapter 类。您可以通过调用 getAddress 方法来实现它:

String strAddress = null;
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
// if device does not support Bluetooth
if(bluetoothAdapter==null){
Log.d(TAG,"device doesn't supports bluetooth"); // like in case of emulator
strAddress = null;
} else
strAddress = bluetoothAdapter.getAddress();

关于java - 每个蓝牙设备都有自己唯一的 MAC 地址吗?我们如何在应用程序中访问它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29378724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com