i am trying to catch the physical button events on a motorola ht820
bluetooth headset and it i cannot seem to trap those events.

the media player on the device *is* able to catch those events.

based, on what I've read and googled for, it seems like this should do
the trick --

                rec = new BroadcastReceiver() {
                        @Override
                        public void onReceive(Context context, Intent intent) {
                    KeyEvent event = (KeyEvent) intent.getParcelableExtra
(Intent.EXTRA_KEY_EVENT);
                    if (event != null && event.getAction() ==
KeyEvent.ACTION_DOWN) {
                        switch (event.getKeyCode()) {
                        case KeyEvent.KEYCODE_HEADSETHOOK:
                        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                                                getInstance().playpause();
                            abortBroadcast();
                                break;
                        case KeyEvent.KEYCODE_MEDIA_STOP:
                                getInstance().stop(true);
                                abortBroadcast();
                                break;
                        case KeyEvent.KEYCODE_MEDIA_NEXT:
                                getInstance().next();
                                abortBroadcast();
                                break;
                        case KeyEvent.KEYCODE_VOLUME_UP:
                                AudioManager audioMgrUp = (AudioManager)
getSystemService(Context.AUDIO_SERVICE);
                                audioMgrUp.adjustStreamVolume(
                                        AudioManager.STREAM_MUSIC, 
AudioManager.ADJUST_RAISE,
AudioManager.FLAG_SHOW_UI);
                                break;
                        case KeyEvent.KEYCODE_VOLUME_DOWN:
                                AudioManager audioMgrDown = (AudioManager)
getSystemService(Context.AUDIO_SERVICE);
                                audioMgrDown.adjustStreamVolume(
                                                AudioManager.STREAM_MUSIC, 
AudioManager.ADJUST_LOWER,
AudioManager.FLAG_SHOW_UI);
                                break;
                        }
                    }
                        }
                };

        // Use a separate receiver for ACTION_MEDIA_BUTTON broadcasts,
        // since we need to manually adjust its priority (to make sure
        // we get these intents *before* the media player.)
        IntentFilter intentFilter = new IntentFilter(
                Intent.ACTION_MEDIA_BUTTON);

but it does not seem to work.

Here's what I'm seeing in the logcat.

any ideas?  tia.

01-25 07:39:53.338: WARN/AudioFlinger(45): write blocked for 54 msecs
01-25 07:39:53.388: ERROR/MediaPlaybackService(652): BadQueue
mPlayListLen : 0 mAlbumListLen : 0 mShrinkAlbumListLen : 0
01-25 07:39:53.398: WARN/AudioFlinger(45): write blocked for 56 msecs
01-25 07:39:53.428: DEBUG/MediaButtonIntentReceiver(652): > onReceive
<
01-25 07:39:53.448: INFO/BluetoothA2dpService.cpp(23187): ACVRCP :
Remote Pannel Pressed with Channel:0
01-25 07:39:53.458: INFO/BluetoothA2dpService.cpp(23187): Panel
Opcode: 0x4c
01-25 07:39:53.498: DEBUG/MediaButtonIntentReceiver(652): > onReceive
<
01-25 07:39:53.508: VERBOSE/MediaPlaybackService(652): onStart
01-25 07:39:53.518: ERROR/MediaPlaybackService(652): MediaMode:Local
01-25 07:39:53.518: DEBUG/MediaPlaybackService(652): CMDPREVIOUS
01-25 07:39:53.558: ERROR/MediaPlaybackService(652): BadQueue
mPlayListLen : 0 mAlbumListLen : 0 mShrinkAlbumListLen : 0
01-25 07:39:53.588: WARN/AudioFlinger(45): write blocked for 146 msecs
01-25 07:39:53.658: INFO/BluetoothA2dpService.cpp(23187): ACVRCP :
Remote Pannel Released with Channel:0
01-25 07:39:53.668: INFO/BluetoothA2dpService.cpp(23187): Panel
Opcode: 0x4c
01-25 07:39:53.698: WARN/AudioFlinger(45): write blocked for 62 msecs
01-25 07:39:53.738: DEBUG/MediaButtonIntentReceiver(652): > onReceive
<
01-25 07:39:53.968: INFO/BluetoothA2dpService.cpp(23187): ACVRCP :
Remote Pannel Pressed with Channel:0
01-25 07:39:53.978: DEBUG/MediaButtonIntentReceiver(652): > onReceive
<
01-25 07:39:53.988: VERBOSE/MediaPlaybackService(652): onStart
01-25 07:39:53.988: ERROR/MediaPlaybackService(652): MediaMode:Local
01-25 07:39:53.988: DEBUG/MediaPlaybackService(652): CMDNEXT
01-25 07:39:53.988: DEBUG/MediaPlaybackService(652): next
mPlayOnNextPrev=true
01-25 07:39:54.028: ERROR/MediaPlaybackService(652): BadQueue
mPlayListLen : 0 mAlbumListLen : 0 mShrinkAlbumListLen : 0

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to