Code example for BluetoothSocket

Methods: connect

0
 
    	log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket connecting to device...");
    	try { 
    		// Connect the device through the socket. This will block 
    		// until it succeeds or throws an exception 
    		mmBluetoothSocket.connect();
    		log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket connecting to device - SUCCEEDED");
    		sendBluetoothDeviceConnectionMessage(DeviceGatewayService.ServiceMessage.BLUETOOTH_DEVICE_CONNECTED.ordinal()); 
    	} catch (IOException connectException) {
    		// Unable to connect; close the socket and get out 
    		log.debug(CLASS + getId() + ": mmBluetoothRfcommSocket connecting to device - FAILED");
//    		sendBluetoothDeviceConnectionMessage(BLUETOOTH_DEVICE_CONNECT_FAILED); 
    		try { 
    			mmBluetoothSocket.close();
    		} catch (IOException closeException) { }
    		return; 
    	}  
    } 
     
    // Do work to manage the connection (in a separate thread) 
    private void sendBluetoothDeviceConnectionMessage(int connectionResult) {