From e8e168355eae98f9c6e46253c45b641cf4fb821d Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 28 Dec 2020 23:29:37 +0100 Subject: [PATCH] catch exceptions thrown at showing alarms --- .../com/simplemobiletools/clock/receivers/AlarmReceiver.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt index a9442c2b..60200b52 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.clock.activities.ReminderActivity import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.clock.helpers.ALARM_ID import com.simplemobiletools.clock.helpers.ALARM_NOTIF_ID +import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.helpers.isOreoPlus class AlarmReceiver : BroadcastReceiver() { @@ -59,7 +60,11 @@ class AlarmReceiver : BroadcastReceiver() { .setCategory(NotificationCompat.CATEGORY_ALARM) .setFullScreenIntent(pendingIntent, true) - notificationManager.notify(ALARM_NOTIF_ID, builder.build()) + try { + notificationManager.notify(ALARM_NOTIF_ID, builder.build()) + } catch (e: Exception) { + context.showErrorToast(e) + } } else { Intent(context, ReminderActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)