summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/src/org/rockbox/RockboxService.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
index 4f5df62280..912142c7a1 100644
--- a/android/src/org/rockbox/RockboxService.java
+++ b/android/src/org/rockbox/RockboxService.java
@@ -80,6 +80,7 @@ public class RockboxService extends Service
80 public void onCreate() 80 public void onCreate()
81 { 81 {
82 instance = this; 82 instance = this;
83 mMediaButtonReceiver = new MediaButtonReceiver(this);
83 } 84 }
84 85
85 public static RockboxService get_instance() 86 public static RockboxService get_instance()
@@ -145,6 +146,9 @@ public class RockboxService extends Service
145 e.printStackTrace(); 146 e.printStackTrace();
146 } 147 }
147 } 148 }
149 /* (Re-)attach the media button receiver, in case it has been lost */
150 mMediaButtonReceiver.register();
151
148 if (resultReceiver != null) 152 if (resultReceiver != null)
149 resultReceiver.send(RESULT_SERVICE_RUNNING, null); 153 resultReceiver.send(RESULT_SERVICE_RUNNING, null);
150 } 154 }
@@ -175,8 +179,6 @@ public class RockboxService extends Service
175 fb = new RockboxFramebuffer(this); 179 fb = new RockboxFramebuffer(this);
176 if (resultReceiver != null) 180 if (resultReceiver != null)
177 resultReceiver.send(RESULT_FB_INITIALIZED, null); 181 resultReceiver.send(RESULT_FB_INITIALIZED, null);
178 mMediaButtonReceiver = new MediaButtonReceiver(this);
179 mMediaButtonReceiver.register();
180 Thread rb = new Thread(new Runnable() 182 Thread rb = new Thread(new Runnable()
181 { 183 {
182 public void run() 184 public void run()
@@ -325,6 +327,7 @@ public class RockboxService extends Service
325 { 327 {
326 super.onDestroy(); 328 super.onDestroy();
327 mMediaButtonReceiver.unregister(); 329 mMediaButtonReceiver.unregister();
330 mMediaButtonReceiver = null;
328 /* Make sure our notification is gone. */ 331 /* Make sure our notification is gone. */
329 stopForeground(); 332 stopForeground();
330 } 333 }