Fixed crash if BluetoothAdapter.STATE_ON is received twice.

This commit is contained in:
Felix Ableitner 2015-07-07 23:18:07 +02:00
parent 3f19e86c75
commit b1bb4eb8b3

View file

@ -143,7 +143,8 @@ class BluetoothInterface(context: Context, mainHandler: Handler,
override def onReceive(context: Context, intent: Intent): Unit = {
intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) match {
case BluetoothAdapter.STATE_ON =>
startBluetoothConnections()
if (!listenThread.isAlive)
startBluetoothConnections()
case BluetoothAdapter.STATE_TURNING_OFF =>
Log.i(Tag, "Bluetooth disabled, stopping connectivity")
listenThread.cancel()