Catch a foreground service start exception.

This commit is contained in:
Greyson Parrelli
2022-10-07 09:52:23 -04:00
parent 50ded5c92a
commit 04b0c01015

View File

@@ -83,7 +83,12 @@ object FcmFetchManager {
context.stopService(Intent(context, FcmFetchBackgroundService::class.java))
if (startedForeground) {
context.startService(FcmFetchForegroundService.buildStopIntent(context))
try {
context.startService(FcmFetchForegroundService.buildStopIntent(context))
} catch (e: IllegalStateException) {
Log.w(TAG, "Failed to stop the foreground notification!", e)
}
startedForeground = false
}
}