蓝牙设备自动断开

时间:2017-04-19 12:18:27

标签: android bluetooth

我不知道这个问题是不是正确的平台。

我正在使用广播接收器检查蓝牙设备是否已连接。

使用以下代码。

  //The BroadcastReceiver that listens for bluetooth broadcasts
    private final BroadcastReceiver mBG5Receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            String bg5Tag="Bluetooth";
            String action = intent.getAction();
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            Log.e("Device state",Integer.toString(device.getBondState()));
            Log.i("Action is ",action);

            BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();


            else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
            //Device is now connected
                Log.d(bg5Tag,"Action connected");
                Log.e("Device name ",device.getName());

            }
            else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
            //Done searching
                Log.d(bg5Tag,"Action searching");
                Log.e("Device name ",device.getName());

            }
            else if (BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)) {
            //Device is about to disconnect
                Log.d(bg5Tag,"Action about disconnect");
                Log.e("Device name ",device.getName());

            }
            else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
            //Device has disconnected
                Log.d(bg5Tag,"Action disconnected");
                Log.e("Device name ",device.getName());
            }
            else if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)){
                Log.d(bg5Tag,"Action pairing request");
                Log.e("Device name ",device.getName());
            }
        }
    };

但是当我点击设备以配对然后设备自动断开连接时。但它已移至配对设备列表。为什么要断开连接?

0 个答案:

没有答案