Skip to content

Commit 8c1264f

Browse files
committed
Fixes a bug
1 parent 1214071 commit 8c1264f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

presentation/src/main/java/com/jorge/boats/xkcd/task/UserRetentionGcmTaskService.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.app.PendingIntent;
66
import android.content.Context;
77
import android.content.Intent;
8+
import android.support.annotation.NonNull;
89
import android.support.annotation.Nullable;
910
import android.support.v4.app.NotificationCompat;
1011

@@ -21,10 +22,15 @@ public class UserRetentionGcmTaskService extends GcmTaskService {
2122

2223
@Override
2324
public int onRunTask(final @Nullable TaskParams taskParams) {
24-
if (System.currentTimeMillis() - Long.parseLong(P.lastOpenedEpoch.get()) > APP_IGNORED_LIMIT_MILLISECONDS) {
25-
showReengageNotification();
25+
try {
26+
if (System.currentTimeMillis() - Long.parseLong(P.lastOpenedEpoch.get()) > APP_IGNORED_LIMIT_MILLISECONDS) {
27+
showReengageNotification();
28+
}
29+
return GcmNetworkManager.RESULT_SUCCESS;
30+
} catch (final @NonNull NumberFormatException e) {
31+
//The preference has not been written yet, so just reschedule and move on
32+
return GcmNetworkManager.RESULT_RESCHEDULE;
2633
}
27-
return GcmNetworkManager.RESULT_SUCCESS;
2834
}
2935

3036
private void showReengageNotification() {

0 commit comments

Comments
 (0)