简体   繁体   中英

Why am I not able to connect to device via Bluetooth android?

I am able to pair devices with the android studio app but I get the tag

"CouldNotConnectToSocket" even though the device is paired.

I am new to android studio so I am really stuck with where to go next.

I also get

getBluetoothService() called with no BluetoothManagerCallback

The UUID I created is:

private final static UUID BTMODULEUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

Can anyone please help me?

new Thread() {
            @Override
            public void run() {
                device = BA.getRemoteDevice(address);
                try {
                    BTSocket = device.createRfcommSocketToServiceRecord(BTMODULEUUID);
                    //BTSocket = createBluetoothSocket(device);
                    Log.d(TAG, "Device Connected");
                    BA.cancelDiscovery();
                    BTSocket.connect();
                } catch (IOException ex) {
                    Log.d(TAG, "CouldNotConnectToSocket");
                    closeSocket(BTSocket);
                }
            }
            }.start();

The issue I found out was that the devices I was trying to connect to send data back and forth require Bluetooth Low Energy support from the app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM