Code example for BluetoothAdapter: Communicating over Bluetooth

Methods: cancelDiscovery, isDiscovering, startDiscovery

3
 
        // Indicate scanning in the title 
        setProgressBarIndeterminateVisibility(true);
 
        // If we're already discovering, stop it 
        if (mBtAdapter.isDiscovering()) {
            mBtAdapter.cancelDiscovery();
        } 
 
        // Request discover from BluetoothAdapter 
        mBtAdapter.startDiscovery();
    } 
 
    // The BroadcastReceiver that listens for discovered devices and 
    // changes the title when discovery is finished 
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override 
        public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction(); 
 
            // When discovery finds a device