Add Event Listener for Failing to Enable Bluetooth SCO
pro2on opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
Currently, the library offers functionality for enabling Bluetooth SCO, but it does not provide an event or callback to handle cases where enabling Bluetooth SCO fails. This leaves developers without a straightforward way to manage errors or inform users about the issue.
I also encountered issue #148, "Fail to Connect to Bluetooth Headset." It would be helpful to have a feature that notifies users when switching to a Bluetooth headset has failed.
Describe the solution you'd like
It can be a callback or listener, which we can setup through audioSwitch class.
Describe alternatives you've considered
I'm not entirely certain that this is the optimal solution, but at the moment, I'm employing a combination of Handler.postDelayed and a broadcast receiver with the AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED filter. When a user selects a Bluetooth headset as the active device, I initiate a timer. After the timeout period, I check to see if my broadcast receiver has registered the SCO_AUDIO_STATE_CONNECTED event.