Prevent crash

pull/162/head
M66B 6 years ago
parent a899e4e19a
commit d50cb158d1

@ -168,25 +168,37 @@ public class ServiceSynchronize extends ServiceBase {
Map<Long, List<Long>> groupNotifying = new HashMap<>(); Map<Long, List<Long>> groupNotifying = new HashMap<>();
// Get existing notifications // Get existing notifications
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); try {
for (StatusBarNotification sbn : nm.getActiveNotifications()) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String tag = sbn.getTag(); for (StatusBarNotification sbn : nm.getActiveNotifications()) {
if (tag != null && tag.startsWith("unseen.")) { String tag = sbn.getTag();
String[] p = tag.split(("\\.")); if (tag != null && tag.startsWith("unseen.")) {
long group = Long.parseLong(p[1]); String[] p = tag.split(("\\."));
long id = Long.parseLong(p[2]); long group = Long.parseLong(p[1]);
long id = Long.parseLong(p[2]);
if (!groupNotifying.containsKey(group))
groupNotifying.put(group, new ArrayList<>()); if (!groupNotifying.containsKey(group))
groupNotifying.put(group, new ArrayList<>());
if (id > 0) {
Log.i("Notify restore " + tag); if (id > 0) {
groupNotifying.get(group).add(id); Log.i("Notify restore " + tag);
groupNotifying.get(group).add(id);
}
} }
} }
} 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>>() { db.message().liveUnseenNotify().observe(cowner, new Observer<List<TupleMessageEx>>() {
private ExecutorService executor = private ExecutorService executor =

Loading…
Cancel
Save