Want to grab a button on a bluetooth headset

For now, I just want to display the pressed button! when I press any button (volume or call button) on the paired Bluetooth headset (LG HBM-770). I tried the exact method here (this is the code I'm using): Android - registering the headset button with BroadcastReceiver without any luck, including the proposed fixes, Google search clock only indicates this type of code. Bluetooth permission is allowed in the manifest.

If I press the call button right now, it seems to never get into my application, instead a menu appears asking you to choose which application will process (voice search, Google voice, etc.). If I hold the Bluetooth call button, my phone calls the last number dialed. If I try to replace the Intent filter type with ACTION_POWER_DISCONNECTED, it works flawlessly when I turn off the power, so it seems that the code from this point is working fine.

It would be nice if I didn’t use any filter at all, and Toast simply appeared, displaying the identifier of ANY action received, so I know how the buttons on the phone look exactly.

+4
source share
1 answer

When you press the call button on the bluetooth headset, some AT commands will be launched (check Hands Free Spec) to make a phone call that the phone will take care of, for example: when the call button is pressed for a long time, the headset will send an AT command to redial the number, and so on other customs.

The tasks and methods specified in the link are a button pressed on the phone.

+1
source

Source: https://habr.com/ru/post/1445429/


All Articles