aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-27 13:47:25 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-27 13:47:25 -0800
commit9d94da79d7d7a163786ca0402a3a6addea8c06e5 (patch)
tree89617f8de3afa6bde9c68c178e38d2f8ef6d19f7
parent29999436f50a4ea8cf5f47732f1b45af52a62856 (diff)
downloaddsub-9d94da79d7d7a163786ca0402a3a6addea8c06e5.tar.gz
dsub-9d94da79d7d7a163786ca0402a3a6addea8c06e5.tar.bz2
dsub-9d94da79d7d7a163786ca0402a3a6addea8c06e5.zip
Ignore pause events if app is off
-rw-r--r--src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java b/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java
index 89a4a87b..8119ef2d 100644
--- a/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java
+++ b/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java
@@ -36,18 +36,22 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
+ if(DownloadService.getInstance() == null && (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_STOP ||
+ event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || event.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK)) {
+ Log.w(TAG, "Ignore keycode event because downloadService is off");
+ return;
+ }
Log.i(TAG, "Got MEDIA_BUTTON key event: " + event);
Intent serviceIntent = new Intent(context, DownloadService.class);
serviceIntent.putExtra(Intent.EXTRA_KEY_EVENT, event);
context.startService(serviceIntent);
- if (isOrderedBroadcast())
- {
- try {
- abortBroadcast();
- } catch (Exception x) {
- // Ignored.
+ if (isOrderedBroadcast()) {
+ try {
+ abortBroadcast();
+ } catch (Exception x) {
+ // Ignored.
+ }
}
- }
}
}