diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-02-27 13:47:25 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-02-27 13:47:25 -0800 |
commit | 9d94da79d7d7a163786ca0402a3a6addea8c06e5 (patch) | |
tree | 89617f8de3afa6bde9c68c178e38d2f8ef6d19f7 /src/github | |
parent | 29999436f50a4ea8cf5f47732f1b45af52a62856 (diff) | |
download | dsub-9d94da79d7d7a163786ca0402a3a6addea8c06e5.tar.gz dsub-9d94da79d7d7a163786ca0402a3a6addea8c06e5.tar.bz2 dsub-9d94da79d7d7a163786ca0402a3a6addea8c06e5.zip |
Ignore pause events if app is off
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java | 18 |
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. + } } - } } } |