Android mute button - android

Some new Android devices have a mute button like Iphone. Its an actual physical button that allows you to mute an incoming call instead of long pressing the volume down hardware control or the pressing the power button.
my question: What is the keycode event for this or how can i capture it so i can get my app to respond to it ?

I think you're looking for KeyEvent.KEYCODE_MUTE. Note that no flagship Android devices have this button, so you are left to the mercy of whether or not the manufacturer's OS actually sends this event or not.

Related

How to override (or at least listen to) bluetooth headset volume buttons on android?

I would like to control my app with a headset keys (volume +, middle key, volume -).
I have no problem detecting media keys:
play/pause, triggered by click on middle
next/previous, triggered by volume buttons long press
I do have a problem detecting (and ideally intercepting) everything else. I am especially interested in volume keys.
!! Solutions with onKeyDown or listening to MEDIA_BUTTON or listening to volume changes (e.g. via AudioService) work with phone volume keys, but not with bluetooth volume keys !!
More info:
(just as info) In activity on onKeyDown I do not see headset key presses (it only picks up clicks on phone volume rocker).
I cannot infer clicks from volume changes, as there is no trigger if the device is at max/min volume. Also the volume dialog does not show up if I try to set above max volume with headset, as it does with phone volume buttons.
In debugger, the only thing that happens upon vol+ on max volume is some action reported from avrcp in debug mode:
07:04:08.220 7106-7250/? I/BluetoothAvrcpServiceJni: btavrcp_volume_change_callback
07:04:08.220 7106-30330/? V/Avrcp: MSG_NATIVE_REQ_VOLUME_CHANGE: volume=127 ctype=13
07:04:08.281 5937-13180/? I/EDMNativeHelperService: isAVRCPProfileEnabled
07:04:08.285 7106-7250/? I/BluetoothAvrcpServiceJni: btavrcp_volume_change_callback
07:04:08.285 7106-30330/? V/Avrcp: MSG_NATIVE_REQ_VOLUME_CHANGE: volume=127 ctype=15
How could I get these events with my service? Or is there any useful alternative to detect such headset clicks?

Android Wake up app on bluetooth keyboard key pressed

I'm trying to develop an app that recognizes when a paired bluetooth keyboard's key is pressed and wakes up the app with certain action. The bluetooth device in particular is the Selfie Remote Shutter (this one, no ads intended: http://www.ebay.es/itm/like/361219097614) and it's recognized by the device as a bluetooth keyboard. It sends two different events which the SO in Android identifies as key volume up pressed and enter key pressed.
I've declared a receiver for my app and tried to listen to every bluetooth action in order to identify the command sent from the keyboard to my device, capture that event and trigger certain method in my app, even if it's not open.
I don't know how to achieve this, since when the app is opened, I can override the onKeyDown event and recognize which "key" has the bluetooth keyboard pressed, but can't figure how to achieve that with the app closed. Maybe some intent-filter?
Thanks in advance!

Android update widget on hardware button press

Is it possible to update an android widget when hardware button is pressed (side volume button, for instance)?
No, this is not possible as you cannot listen to events on the volume, power, home, back and menu buttons if your app is not in the foreground.
On some device you may listen to the camera button, but that is present on very few devices.

Want to capture a bluetooth headset button press

For now, I just want to display a "button pressed!" message when I press any button (volume or the call button) on a paired bluetooth headset (LG HBM-770). I've tried the exact method here (this is the code I'm using): Android - registering a headset button click with BroadcastReceiver with no luck, including the suggested fixes. Hours of google searching only point to that type of code. Bluetooth permission is enabled in the manifest.
If I press the call button now, it seems to never get to my app, instead it brings up the menu that asks you to choose which app to handle it (voice search, google voice, etc). If I hold down the bluetooth call button, my phone calls the last dialed number. If I try to replace the Intent filter type with ACTION_POWER_DISCONNECTED, it works flawlessly when I disconnect power, so it seems that the code from that point on works fine.
It would be nice if I could use no filter at all, and just have a Toast pop up displaying the ID of ANY action received, so I know what exactly the buttons look like to the phone.
Prssing call button on bluetooth headset will trigger certain AT commands(check in Hands Free Spec) to phone which phone will take care, ex: when pressed call button for long duration, headset will send an AT command for call redial and so are the other usecases.
Intents and the methods provided in the link are for the button pressed on the phone.

Creating 'middleman' headset button controller in Android

All,
I have searched for an answer to this, but I'm not getting anything exact... It's my first time writing an Android app, so please be gentle :)
I'm pretty bummed about the minimal headset support in Android - unlike e.g. iPhone, it only natively seems to support a single button, so no volume control on headset compatibility. Additionally, if I'm listening to music and a call comes in, the OS pauses the music automatically, but the headset button still functions ONLY as a media button - I can't use it to answer/end the call. If I answer the call via the screen and press the headset button, the music starts again, but the call continues...
I'd like to create a 'middleman' app that can pick up that the headset button has been pressed (via Keyevent.KEYCODE_HEADSETHOOK) and can then determine whether to perform the default ACTION_MEDIA_BUTTON action (toggle play/pause in my chosen media player) or, if there is an incoming call, pause the music and answer the phone (and then, when pressed again, end the call and restart the media player). Perhaps even check for ACTION_MULTIPLE on the headset button to assign different options (ACTION_MEDIA_NEXT, ACTION_MEDIA_PREVIOUS etc.). Perhaps also be able to determine whether different buttons on the headset have been pressed (if the headset is e.g. a fancy iPhone headset) and 'translate' those button presses into the appropriate ACTION_MEDIA_*). This might not be possible if the OS can't tell the difference between different buttons, obviously.
Obviously such an app would have to receive the intent with a high enough priority that it would be able to abort the broadcast before the current media player gets it.
I've been tinkering with creating assorted BroadcastReceiver classes and intent filters etc., but part of the problem is that the bult-in Android emulator that comes with Eclipse doesn't seem to have the ability to simulate a user plugging in the headset and/or subsequently clicking the headset button. Therefore, every time I get somethign that looks promising, I have to put it onto my actual phone and try it out - time-consuming and a hassle.
3 questions then:
Am I missing somethign obvious - is this a real problem and if so, has it already been solved?
If it IS a problem, is it possible to write such a middleman app?
Are there any other Android emulators that can check for headset-related activities?
Thanks,
Rory
i´ve already written exactly this kind of app. Its called like the topic of this thead: Headset Button Controller ;-)
http://www.androidpit.com/en/android/market/apps/app/com.kober.headset/Headset-Button-Controller
Cheers Christoph

Categories

Resources