diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt index 1f50efd2..86000cee 100644 --- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt +++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt @@ -210,10 +210,6 @@ class MainActivity : AppCompatActivity(), Logging { tab.icon = ContextCompat.getDrawable(this, tabInfos[position].icon) }.attach() - model.connectionState.observe(this) { connected -> - updateConnectionStatusImage(connected) - } - // Handle any intent handleIntent(intent) } @@ -638,6 +634,11 @@ class MainActivity : AppCompatActivity(), Logging { unregisterMeshReceiver() // No point in receiving updates while the GUI is gone, we'll get them when the user launches the activity unbindMeshService() + scanModel.changeDeviceAddress.removeObservers(this) + model.connectionState.removeObservers(this) + bluetoothViewModel.enabled.removeObservers(this) + model.requestChannelUrl.removeObservers(this) + super.onStop() } @@ -658,6 +659,10 @@ class MainActivity : AppCompatActivity(), Logging { } } + model.connectionState.observe(this) { connected -> + updateConnectionStatusImage(connected) + } + bluetoothViewModel.enabled.observe(this) { enabled -> if (!enabled && !requestedEnable && scanModel.selectedBluetooth) { requestedEnable = true