Back to project page DoomPlay.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUC...
If you think the Android project DoomPlay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.perm.DoomPlay; /*from www . j a v a 2s . co m*/ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.view.KeyEvent; public class MediaButtonReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent) intent .getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null ) return; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_STOP: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: context.startService(new Intent(PlayingService.actionPlay)); break; case KeyEvent.KEYCODE_MEDIA_NEXT: context.startService(new Intent(PlayingService.actionNext)); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: context.startService(new Intent(PlayingService.actionPrevious)); break; } this.abortBroadcast(); } else if (android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intent.getAction())) { context.startService(new Intent(PlayingService.actionClose)); } } }