Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling headset buttons before Voice Search on Jelly Bean

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.

like image 561
tvkanters Avatar asked Jul 12 '12 12:07

tvkanters


1 Answers

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.

like image 143
Bryan Herbst Avatar answered Oct 22 '22 08:10

Bryan Herbst