![](/img/trans.png)
[英]How to manage a Bluetooth connection on Android through configuration changes?
[英]How to filter bluetooth tags through android apps
与应用配对时如何过滤蓝牙标签。 例如,“瓷砖”不与除其授权标签以外的其他标签连接。 我的问题是,他们如何通过应用识别他们的授权标签?
一种简单的解决方案是连接到不受信任的设备,发送预期具有特定结果的信号,如果接收良好,则“信任”该设备。
然后,在下次加载时,检查配对的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");
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.