connect to non-discoverable bluetooth device

后端 未结 3 688
刺人心
刺人心 2021-02-15 15:30

I am developing an app for android. Just a general questions as to , if is it possible to connect to a device which is non discoverable publicly?

Thanks in advance.

3条回答
  •  一生所求
    2021-02-15 15:38

    If you have previously paired with the device then it is possible to connect to it again even if it is not in discoverable mode. See this post: programmatically-connect-to-paired-bluetooth-device

        // use paired devices or create a BluetoothDevice using a mac address
        //Set pairedDevices = mBluetoothAdapter.getBondedDevices();
        BluetoothAdapter myAdapter = BluetoothAdapter.getDefaultAdapter();
        BluetoothDevice remoteDevice = myAdapter.getRemoteDevice("00:00:00:00:00:00");
        BluetoothSockt btSocket = remoteDevice.createRfcommSocketToServiceRecord(UUID);
        btSocket.connect();
        //get input and output stream etc...
    

提交回复
热议问题