audioswitch: java.lang.IllegalArgumentException: Receiver not registered: com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager
Describe the bug
Recently in 1.1.3 you added support for Android 12, which is great although I’m getting a crash when trying to stop() the AudioManager if the BLUETOOTH_CONNECT permission was granted while on a call.
Also, it’s worth mentioning that in 1.1.3 version AudioDeviceChangeListener is inconsistently firing off unexpected events with an incorrectly selected audio device.
To Reproduce Steps to reproduce the behavior:
- Start AudioManager.
- Grant
BLUETOOTH_CONNECTpermission. - Stop Audio Manager.
- Crash
Expected behavior The app shouldn’t crash.
Actual behavior The app crashes.
Application Logs
Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager@bb582b7
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1555)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1789)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:769)
at com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager.stop(BluetoothHeadsetManager.kt:173)
at com.twilio.audioswitch.AudioSwitch.closeListeners(AudioSwitch.kt:356)
at com.twilio.audioswitch.AudioSwitch.stop(AudioSwitch.kt:179)
AudioSwitch Version
- Version: 1.1.3
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (9 by maintainers)
Release made with crash fixes @4brunu @zalyssas @mykola-tarchanyn
@afriedmanGlacier for what it’s worth you can get the list of bluetooth headsets using just audio manager. (No bluetooth permission required on android 12 so no messing with the bluetooth manager and thus no possible crash.) I was running into the same issue as you and that’s how I worked-around it.
And filter by the
AudioDeviceInfotype.