Code example for BluetoothDevice

Methods: createRfcommSocketToServiceRecord

            BluetoothSocket tmp = null;
            // Get a BluetoothSocket for a connection with the 
            // given BluetoothDevice 
            try { 
                tmp = device.createRfcommSocketToServiceRecord(SPP_UUID);
            } catch (IOException e) {
                Log.e(TAG, "create() failed", e);
            mmSocket = tmp;
        public void run() { 
            Log.i(TAG, "BEGIN mConnectThread");
            // Always cancel discovery because it will slow down a connection 
            // Make a connection to the BluetoothSocket 
Connect your IDE to all the code out there  Get Codota for Java