diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-02-23 01:10:54 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-02-23 01:10:54 +0000 |
commit | 95e24dd7a54256e8df56e347c0f43133087a1df2 (patch) | |
tree | 677d66d4e72fedfe134bca103ed98b5792da1440 /android/src/org/rockbox/Helper | |
parent | da3417706d927c7da0b59351fa8cc010d63d7928 (diff) |
Android:
* Re-create RockboxFramebuffer instance with every time there's a new Activity.
* Also, allow Rockbox to be started via multimedia buttons, immediately starting playback if wanted.
We don't need to keep the fb instance around when it backround, and it makes us less depending on it and the activity (less race conditions). And this is how you usually do it in Android apps.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29384 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src/org/rockbox/Helper')
-rw-r--r-- | android/src/org/rockbox/Helper/MediaButtonReceiver.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/android/src/org/rockbox/Helper/MediaButtonReceiver.java b/android/src/org/rockbox/Helper/MediaButtonReceiver.java index 3749cec32a..a57bdd4831 100644 --- a/android/src/org/rockbox/Helper/MediaButtonReceiver.java +++ b/android/src/org/rockbox/Helper/MediaButtonReceiver.java @@ -22,9 +22,8 @@ package org.rockbox.Helper; import java.lang.reflect.Method; - +import org.rockbox.RockboxFramebuffer; import org.rockbox.RockboxService; - import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -73,7 +72,12 @@ public class MediaButtonReceiver /* helper class for the manifest */ public static class MediaReceiver extends BroadcastReceiver - { + { + private void startService(Context c, Intent baseIntent) + { + baseIntent.setClass(c, RockboxService.class); + c.startService(baseIntent); + } @Override public void onReceive(Context context, Intent intent) { @@ -81,8 +85,11 @@ public class MediaButtonReceiver { KeyEvent key = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (key.getAction() == KeyEvent.ACTION_UP) - { /* pass the pressed key to Rockbox */ - if (RockboxService.get_instance().get_fb().dispatchKeyEvent(key)) + { /* pass the pressed key to Rockbox, starting it if needed */ + RockboxService s = RockboxService.get_instance(); + if (s == null || !s.isRockboxRunning()) + startService(context, intent); + else if (RockboxFramebuffer.buttonHandler(key.getKeyCode(), false)) abortBroadcast(); } } |