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:
> 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:
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, deepdr...@googlemail.com <
> On Jan 30, 8:20 pm, Brodsky <peter.brod...@gmail.com> 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:
On Sun, Feb 1, 2009 at 1:01 AM, Nick Pelly <npe...@google.com> wrote: > 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
> Hi,
Can you please write in some more details relate to headset button mapping ? I got stuck here, I don't know how to go ahead. I am trying to find out where I should hook my headset button press event ?
>> On Jan 30, 8:20 pm, Brodsky <peter.brod...@gmail.com> 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:
>> > 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 android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers-unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -~----------~----~----~----~------~----~------~--~---
On Sun, Feb 1, 2009 at 1:01 AM, Nick Pelly <npe...@google.com> wrote: > 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
> Hi Nick,
My headset driver maps button press to KEYCODE_CALL.
I have resolved this issue with condition check in PhoneWindowsManager.c. Now I can use my wired headset button to either receive or end incoming call. is this proper way to fix this issue ?
>> On Jan 30, 8:20 pm, Brodsky <peter.brod...@gmail.com> 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:
>> > 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 android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers-unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -~----------~----~----~----~------~----~------~--~---
For a media application you need to register a broadcast receiver for Intent.ACTION_MEDIA_BUTTON and then when the callback is called you want to handle the following key codes:
These key codes are sent from Bluetooth devices such as headphones and in car stereos: KEYCODE_MEDIA_PLAY_PAUSE KEYCODE_MEDIA_NEXT KEYCODE_MEDIA_PREVIOUS KEYCODE_MEDIA_FAST_FORWARD KEYCODE_MEDIA_REWIND KEYCODE_MEDIA_STOP
This key code is sent from the wired headset call button: KEYCODE_HEADSETHOOK
> For a media application you need to register a broadcast receiver for > Intent.ACTION_MEDIA_BUTTON and then when the callback is called you > want to handle the following key codes:
> These key codes are sent from Bluetooth devices such as headphones and > in car stereos: > KEYCODE_MEDIA_PLAY_PAUSE > KEYCODE_MEDIA_NEXT > KEYCODE_MEDIA_PREVIOUS > KEYCODE_MEDIA_FAST_FORWARD > KEYCODE_MEDIA_REWIND > KEYCODE_MEDIA_STOP
> This key code is sent from the wired headset call button: > KEYCODE_HEADSETHOOK
> Good luck!
Please could you post a snippet? I am not getting any result trying to catch those key codes...i'm working with Galaxy Tab + Samsung HM1500 Bluetooth headset