简体   繁体   中英

How to detect if bluetooth device out of range, or we lost it?

For bluetooth device found we receive Brodcast from Android with action :

if (BluetoothDevice.ACTION_FOUND.equals(action)) {
    // New bluetooth device found    
}

When we set device to discover able then this happens.

My question is what are the intents that are fired when device discoverable is turned off or bluetooth of other device turned off.

In my list view I am showing devices that are "FOUND" I am able to do this using above code. But I want to remove entry of the device which is no longer in range, no longer discoverable or has turned off the bluetooth are there any specific intent that Android platform fires ?

I have looked through BluetoothDevice , BluetoothAdapter reference API s. But did n't found any useful broadcast action.

The intent you are searching for is BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED

Intent used to broadcast the change in connection state of the local Bluetooth adapter to a profile of the remote device.

This intent will have 3 extras:

EXTRA_CONNECTION_STATE or EXTRA_PREVIOUS_CONNECTION_STATE can be:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM