我正在开发一个程序,其中从Android手机,我必须作为客户端连接到蓝牙医疗传感器.我正在使用官方蓝牙API并且在连接期间没有问题(SPP配置文件),但是当我结束插座时,传感器仍然连接到我的手机(虽然我已经关闭了连接).
有没有办法让蓝牙断开连接?我认为有一个名为ACTION_ACL_CONNECTED的意图,它就是这样做的.任何人都可以解释我如何使用它?
提前致谢.
编辑:这是代码,如果有人需要其他信息,它是一个Nonin 4100医疗传感器.
Set<BluetoothDevice> pairedDevices = Activa.myBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
// Add the name and address to an array adapter to show in a ListView
String name = device.getName();
if (name.contains("Nonin")) {
try {
found = true;
// socket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
// handler.sendEmptyMessage(5);
// Activa.myBluetoothAdapter.cancelDiscovery();
// socket.connect();
BluetoothDevice hxm = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(device.getAddress());
Method m;
try {
m = hxm.getClass().getMethod("createRfcommSocket", new …Run Code Online (Sandbox Code Playgroud)