I am working on a VoIP-Android-App and The app needs to be able to accept/decline call thought Bluetooth headset.
But the problem is that after adding connection to SCO
audioManager.startBluetoothSco()
audioManager.isBluetoothScoOn = true
Once I click to the headset button I can hear a sound that usually comes when I accept call using telephony, so I assume that some android system component catch this signal and doesn't throw it further
What I've tried already:
1) Telephony State listener (It is always IDLE)
val tm = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
phoneStateListener = MyPhoneStateListener()
tm.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE)
2) MediaSession + silent noise + media button listener Doesn't work for the first click, second+ clicks handled correctly
3) MEDIA_BUTTON receiver doesn't work
I found a similar question on SO but without the answer how to make it work Accepting a Call via Bluetooth Headset
So is there anyway how I can intercept Bluetooth button click from Bluetooth Headset Service?