From 04a2a12546f427b3a837153842db7c6bbb17a21d Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Jun 2019 15:58:09 +0200 Subject: [PATCH] Prevent crash --- .../java/eu/faircode/email/ServiceSynchronize.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 304bd8686f..32ec200f5e 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -134,8 +134,12 @@ public class ServiceSynchronize extends LifecycleService { @Override public void onChanged(@Nullable TupleAccountStats stats) { if (stats != null && !stats.equals(lastStats)) { - NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(stats).build()); + try { + NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(stats).build()); + } catch (Throwable ex) { + Log.e(ex); + } if (oneshot && stats.operations > 0) onOneshot(true); @@ -163,7 +167,11 @@ public class ServiceSynchronize extends LifecycleService { @Override public void onChanged(List messages) { - Core.notifyMessages(ServiceSynchronize.this, notifying, messages); + try { + Core.notifyMessages(ServiceSynchronize.this, notifying, messages); + } catch (Throwable ex) { + Log.e(ex); + } } });