From 5f6c1c62c068ad0fa4e2fc8de98bd6c2572e68c3 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 16 Mar 2017 16:34:13 -0500 Subject: [PATCH] Check if lastRunPreference is null --- src/main/java/org/tasks/scheduling/MidnightIntentService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/tasks/scheduling/MidnightIntentService.java b/src/main/java/org/tasks/scheduling/MidnightIntentService.java index 145c852d0..f1fead79a 100644 --- a/src/main/java/org/tasks/scheduling/MidnightIntentService.java +++ b/src/main/java/org/tasks/scheduling/MidnightIntentService.java @@ -34,7 +34,8 @@ public abstract class MidnightIntentService extends InjectingIntentService { Preferences preferences = new Preferences(context); AlarmManager alarmManager = new AlarmManager(context, preferences); - long lastRun = preferences.getLong(getLastRunPreference(), 0); + String lastRunPreference = getLastRunPreference(); + long lastRun = lastRunPreference == null ? 0 : preferences.getLong(lastRunPreference, 0); long nextRun = nextMidnight(lastRun); long now = currentTimeMillis();