Im currently working on a android application.. I have to notify the user whenever the bluetooth of the device is turned off while the application is currently running.. How
Register BroadcastReceiver with intent action BluetoothAdapter.ACTION_STATE_CHANGED
and move your notifiyng code into onReceive
method. Don't forget to check if new state is OFF
if(BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
if(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)
== BluetoothAdapter.STATE_OFF)
// Bluetooth was disconnected
}