From 384bb3759e87cd1438d977471df7d7577fdb2f83 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 25 Jul 2020 20:40:00 -0700 Subject: [PATCH] fix autobug - location callback might come after activty is dead https://console.firebase.google.com/u/0/project/meshutil/crashlytics/app/android:com.geeksville.mesh/issues/714e0b9e232289ddc9162fd3aebc1510?time=last-seven-days&sessionId=5F1C562E03E2000142C73D26354B80BF_DNE_0_v2 --- .../com/geeksville/mesh/ui/SettingsFragment.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt index e8d92f8ed..284ca7f80 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt @@ -810,11 +810,15 @@ class SettingsFragment : ScreenFragment("Settings"), Logging { // exception.startResolutionForResult(this@MainActivity, REQUEST_CHECK_SETTINGS) // For now just punt and show a dialog - Toast.makeText( - requireContext(), - getString(R.string.location_disabled_warning), - Toast.LENGTH_SHORT - ).show() + + // The context might be gone (if activity is going away) by the time this handler is called + context?.let { c -> + Toast.makeText( + c, + getString(R.string.location_disabled_warning), + Toast.LENGTH_SHORT + ).show() + } //} else // Exceptions.report(exception)