From 76b6db375a057129cac64bc157df8b10e2e4a5c9 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 18 Jul 2011 18:56:29 +0000 Subject: Android: Fix sporadic force closes. Android restarts services that are killed during memory pressure. The intent parameter is null then. This caused a null pointer exception. Now replace this null intent with one saying we've been restarted. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30156 a1c6a512-1295-4272-9138-f99709370657 --- android/src/org/rockbox/RockboxService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'android') diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 3182b73b1c..49abb52dd5 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java @@ -167,8 +167,12 @@ public class RockboxService extends Service public int onStartCommand(Intent intent, int flags, int startId) { + /* if null, then the service was most likely restarted by android + * after getting killed for memory pressure earlier */ + if (intent == null) + intent = new Intent("org.rockbox.ServiceRestarted"); do_start(intent); - return 1; /* old API compatibility: 1 == START_STICKY */ + return START_STICKY; } private void startservice() -- cgit v1.2.3