简体   繁体   中英

how to wait till bluetooth is disconnected android

I am switching off the bluetooth on my activity finish. As the calls to disconnect bluetooth are asynchronous, it is going to another activity before completely disconnecting the bluetooth. This behaviour is making the app to hang till the bluetooth is disconnected. So, I am planning to display dialog till bluetooth is disconnected. Any idea on how to achieve it?

You should probably use a Broadcast Receiver with BluetoothDevice.ACTION_ACL_DISCONNECTED .

Refer : http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#ACTION_ACL_DISCONNECTED

For an example, you may refer : http://b2cloud.com.au/tutorial/listening-to-bluetooth-connections/

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