Thursday 27 January 2022

Connect android mobile bluetooth with desktop for mouse and keyboard access

How to connect a bluetooth with desktop and android phone. i able to parring and connect bluetooth but unable to connected with Mouse, keyboard & pen device type.

Below given are both mobile device. but A50 device connect using other app and i want to connect M30s as mouse, keyboard.

enter image description here

private  class ConnectThread extends Thread {
        private final BluetoothSocket mmSocket;
        private final BluetoothDevice mmDevice;

        public ConnectThread(BluetoothDevice device) {
            BluetoothSocket tmp = null;
            mmDevice = device;
            try {
                tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
             
            } catch (IOException e) {
                e.printStackTrace();
            }
            mmSocket = tmp;
        }

        public void run() {
            btAdapter.cancelDiscovery();
            try {
                mmSocket.connect();
            } catch (IOException connectException) {
                try {
                    mmSocket.close();
                } catch (IOException closeException) { }
                return;
            }

            mHandler.obtainMessage(SUCCESS_CONNECT, mmSocket).sendToTarget();
        }


        public void cancel() {
            try {
                mmSocket.close();
            } catch (IOException e) { }
        }
}


from Connect android mobile bluetooth with desktop for mouse and keyboard access

No comments:

Post a Comment