Code example for BluetoothAdapter

Methods: cancelDiscovery

0
    } 
 
    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 { 
    		// 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) { }