Code example for BluetoothDevice

Methods: createRfcommSocketToServiceRecord

1
 
        // Get a BluetoothSocket to connect with the given BluetoothDevice 
        log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket opening...");
        try { 
        	// SPP_UUID is the app's UUID string, also used by the server code 
        	tmp = bluetoothDevice.createRfcommSocketToServiceRecord(SPP_UUID);
        	log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket opening - SUCCEEDED");
        } catch (IOException e)	{
        	log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket opening - FAILED");
        } 
    	mmBluetoothSocket = tmp;
    } 
 
    public void run() { 
        // Cancel discovery because it will slow down the connection 
    	mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    	mBluetoothAdapter.cancelDiscovery();
 
    	log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket connecting to device...");
    	try { 
Contextual code suggestions in your IDE  Get Codota for Java