Code example for BluetoothDevice

Methods: createRfcommSocketToServiceRecord

            Log.i(TAG, getId() + ":begin mConnectThread");
            BluetoothSocket tmp = null;
            // Always cancel discovery because it will slow down a connection 
            try { 
                tmp = mmDevice.createRfcommSocketToServiceRecord(BT_UUID);
            } catch (IOException e) {
                Log.e(TAG, "Socket create() failed", e);
            mmSocket = tmp;
            // Make a connection to the BluetoothSocket 
            if (mAdapter.isEnabled()) mAdapter.cancelDiscovery();
            try { 
                // This is a blocking call and will only return on a 
                // successful connection or an exception 
                if (D)  Log.d(TAG, getId() + ":Connecting to socket...");
                if (D) Log.d(TAG, "connected with remote device: "
                        + mmDevice.getName() + " at address " + mmDevice.getAddress());
Connect your IDE to all the code out there  Get Codota for Java