1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

Check if the bluetoothReceiver is still valid before unregistering it.

Do not set the scan tipe as BT classic if the discovery action has been set by BLE scans.
This commit is contained in:
Daniele Gobbetti 2016-10-03 22:31:33 +02:00
parent dd590528dc
commit bbecfbeace

View File

@ -58,7 +58,9 @@ public class DiscoveryActivity extends GBActivity implements AdapterView.OnItemC
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case BluetoothAdapter.ACTION_DISCOVERY_STARTED:
discoveryStarted(Scanning.SCANNING_BT);
if (isScanning != Scanning.SCANNING_BTLE && isScanning != Scanning.SCANNING_NEW_BTLE) {
discoveryStarted(Scanning.SCANNING_BT);
}
break;
case BluetoothAdapter.ACTION_DISCOVERY_FINISHED:
// continue with LE scan, if available
@ -227,7 +229,11 @@ public class DiscoveryActivity extends GBActivity implements AdapterView.OnItemC
@Override
protected void onDestroy() {
unregisterReceiver(bluetoothReceiver);
try {
unregisterReceiver(bluetoothReceiver);
} catch (IllegalArgumentException e) {
LOG.warn("Tried to unregister Bluetooth Receiver that wasn't registered.");
}
super.onDestroy();
}