Android Jelly Bean introduced a voice search which activates with a long-press on the play/pause button of a headset. As my app requires being able to utilise these long-presses, I was wondering if there is any way to either disable the voice search or make Android play fair with the button events.
Handling headset buttons before Voice Search on Jelly Bean
Asked Answered
I have not tried it myself, but you may be able to get this to work using the AudioManager's registerMediaButtonEventReceiver method, as the volume buttons are media buttons.
The AOSP music app has a MediaButtonIntentReceiver that responds to volume button presses.
Credit for this solution belongs to this answer.
The Pressy app is able to hook a long press of the headset button (even on Lollipop). Pressy has a specific interface with a 'go' button which presumably fires some intent and forces the system to ask if you want to make Pressy or Google Search the default. I would love to know how it achieves it. –
Gulgee
© 2022 - 2024 — McMap. All rights reserved.
registerMediaButtonEventReceiver
to receive button clicks. This part still works, but sadly doesn't make Android give the intent to third party apps before handling Voice Search. – Denominationalism