M. Usman Khan
M. Usman Khan

Reputation: 4458

Custom actions on bluetooth headset buttons

I want to add custom actions when a Bluetooth headset / earpiece buttons are pressed.

Apparently for this I need to listen to Media Events using mediaSession.setCallback(callback)function. But for that I need to also play some Media as well, right? I dont want to play any sound. Can I ask MediaSession to play nothing and just receive the media events?

My goal is to override the default Bluetooth headset actions. How can I achieve that? Or any listener that can listen to all Bluetooth buttons.

Upvotes: 1

Views: 1530

Answers (1)

David Kroukamp
David Kroukamp

Reputation: 36423

I think you might be looking for BluetoothHeadset.

There you can register for events as well as vendor specific events which I'm sure you can use along with your logcat to find out exactly what events are being issued when certain buttons are being clicked.

Here is an example as well that might help getting you started: https://github.com/devunwired/accessory-samples/blob/master/BluetoothAudioProxy/src/com/example/BluetoothAudioProxy/HeadsetService.java

Upvotes: 2

Related Questions