Make some progress on fixing realtime notifications.
[PrivacyCell.git] / app / src / main / java / com / stoutner / privacycell / fragments / SettingsFragment.kt
index f23a1168a91e8ae2e77ddd9f4bd1886df285f570..573cec3fa62fdce2024fdf6d867879a8a048ca83 100644 (file)
@@ -28,6 +28,7 @@ import android.provider.Settings
 
 import androidx.preference.Preference
 import androidx.preference.PreferenceFragmentCompat
+import androidx.work.WorkManager
 
 import com.stoutner.privacycell.R
 import com.stoutner.privacycell.services.RealtimeMonitoringService
@@ -136,6 +137,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
                     } else {  // Realtime monitoring has been disabled.
                         // Stop the realtime monitoring service.
                         requireActivity().stopService(Intent(context, RealtimeMonitoringService::class.java))
+
+                        // Cancel the realtime listener work request.
+                        WorkManager.getInstance(requireContext()).cancelUniqueWork(getString(R.string.register_listener_work_request))
                     }
                 }