catch exceptions thrown at showing alarms

This commit is contained in:
tibbi 2020-12-28 23:29:37 +01:00
parent 5a78285931
commit e8e168355e

View file

@ -16,6 +16,7 @@ import com.simplemobiletools.clock.activities.ReminderActivity
import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.clock.extensions.*
import com.simplemobiletools.clock.helpers.ALARM_ID import com.simplemobiletools.clock.helpers.ALARM_ID
import com.simplemobiletools.clock.helpers.ALARM_NOTIF_ID import com.simplemobiletools.clock.helpers.ALARM_NOTIF_ID
import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.helpers.isOreoPlus import com.simplemobiletools.commons.helpers.isOreoPlus
class AlarmReceiver : BroadcastReceiver() { class AlarmReceiver : BroadcastReceiver() {
@ -59,7 +60,11 @@ class AlarmReceiver : BroadcastReceiver() {
.setCategory(NotificationCompat.CATEGORY_ALARM) .setCategory(NotificationCompat.CATEGORY_ALARM)
.setFullScreenIntent(pendingIntent, true) .setFullScreenIntent(pendingIntent, true)
try {
notificationManager.notify(ALARM_NOTIF_ID, builder.build()) notificationManager.notify(ALARM_NOTIF_ID, builder.build())
} catch (e: Exception) {
context.showErrorToast(e)
}
} else { } else {
Intent(context, ReminderActivity::class.java).apply { Intent(context, ReminderActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)