From d4aeeadb26b19d0eccbf9c9adcfd459d7a3927da Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 7 Nov 2021 09:11:41 -0500 Subject: [PATCH] Avoid crashing when notification channels can't be created/deleted For example, the application may be launched from a service, where channels cannot be deleted. --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 56d03d1f62..137c2af1c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.util.system.AuthenticatorUtil import eu.kanade.tachiyomi.util.system.animatorDurationScale +import eu.kanade.tachiyomi.util.system.logcat import eu.kanade.tachiyomi.util.system.notification import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -158,7 +159,11 @@ open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { } protected open fun setupNotificationChannels() { - Notifications.createChannels(this) + try { + Notifications.createChannels(this) + } catch (e: Exception) { + logcat(LogPriority.ERROR, e) { "Failed to modify notification channels" } + } } private inner class DisableIncognitoReceiver : BroadcastReceiver() {