gpt4 book ai didi

java - 如何通过Android应用程序过滤蓝牙标签

转载 作者:行者123 更新时间:2023-12-01 09:09:58 25 4
gpt4 key购买 nike

如何在与应用程序配对时过滤蓝牙标签。例如,“Tile”不与除其授权标签之外的标签连接。我的问题是,他们如何通过应用程序识别其授权标签?

最佳答案

一个简单的解决方案是连接到不受信任的设备,发送具有特定预期结果的信号,如果接收良好,则“信任”该设备。

然后,在下次加载时,检查配对的 MAC 地址..

类似于:

private BluetoothDevice mDevice = null;
if (mDevice == null) {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null) {
if (mBluetoothAdapter.isEnabled()) {
Set<BluetoothDevice> bluetoothDevices = mBluetoothAdapter
.getBondedDevices();
if (bluetoothDevices != null && bluetoothDevices.size() > 0) {
String bondedID = SharedPreferences.getInstance(
getApplicationContext()
).getPairedAddress();
if (bondedID != null) {
for (final BluetoothDevice device : bluetoothDevices) {
if (device != null
&& device.getAddress().equals(bondedID)) {
mDevice = device;
break;
}
}
}
} else {
Logger.v(TAG, "There are no Bluetooth Paired devices");
}
}
}
}

关于java - 如何通过Android应用程序过滤蓝牙标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40980649/

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