Prevent crash

This commit is contained in:
M66B 2019-09-13 11:50:33 +02:00
parent a899e4e19a
commit d50cb158d1
1 changed files with 26 additions and 14 deletions

View File

@ -168,7 +168,8 @@ public class ServiceSynchronize extends ServiceBase {
Map<Long, List<Long>> groupNotifying = new HashMap<>();
// Get existing notifications
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
for (StatusBarNotification sbn : nm.getActiveNotifications()) {
String tag = sbn.getTag();
@ -186,6 +187,17 @@ public class ServiceSynchronize extends ServiceBase {
}
}
}
} catch (Throwable ex) {
Log.w(ex);
/*
java.lang.RuntimeException: Unable to create service eu.faircode.email.ServiceSynchronize: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.content.pm.ParceledListSlice.getList()' on a null object reference
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2944)
at android.app.ActivityThread.access$1900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:234)
at android.app.ActivityThread.main(ActivityThread.java:5526)
*/
}
db.message().liveUnseenNotify().observe(cowner, new Observer<List<TupleMessageEx>>() {