Reputation: 624
I would like to control my app with a headset keys (volume +, middle key, volume -).
I have no problem detecting media keys:
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?
Upvotes: 4
Views: 1243