For wired headsets, you can use Intent.ACTION_MEDIA_BUTTON as mentioned in
the other thread. This is how the built in media app does pause/play on
wired headset button presses, and where I recommend that you hook in.

For Bluetooth headsets, they do not work like you think. There is no 'button
pressed event' sent by the headset. We don't know when the button is
pressed. Instead the headset maps its buttons presses to commands depending
on its state machine. We receive commands, not button presses from the
headset.

Nick


On Sat, Jan 31, 2009 at 2:07 AM, [email protected] <
[email protected]> wrote:

>
> you may want to look at
>
>
> http://groups.google.com/group/android-developers/browse_thread/thread/1c64cf65f87c9895/1d9464c96b91dbd8?show_docid=1d9464c96b91dbd8
>
>
>
> On Jan 30, 8:20 pm, Brodsky <[email protected]> wrote:
> > Hi!  Does anyone know how to tell when the headset button is being
> > pressed?  I'd like to support the usb headsets and possibly bluetooth
> > headsets.  My app is a media player and ideally, I could register it
> > somewhere so that if no app that uses the headset button has focus it
> > button press would act as a play/pause command in my app. If the phone
> > is ringing or a call is in progress, I'd like to be sensitive to that
> > and let the button do what it normally does: pickup and hang up
> > calls.  we've been trying to chase the button down using this:
> >
> > IntentFilter headsetFilter = new IntentFilter
> > (Intent.ACTION_HEADSET_PLUG);
> > headsetFilter.addAction
> > ("android.intent.action.HEADSET_STATE_CHANGED");
> > headsetFilter.addAction("android.bluetooth.intent.HEADSET_STATE");
> > headsetFilter.addAction
> > ("android.bluetooth.intent.HEADSET_STATE_CHANGED");
> > headsetFilter.addAction
> > ("android.bluetooth.intent.action.MODE_CHANGED");
> > headsetFilter.addAction("android.intent.action.MODE_CHANGED");
> >
> > no luck as of yet.  Any help would be greatly appreciated!  Thanks!
> >
>

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

Reply via email to