twilio/audioswitch

java.lang.IllegalStateException when used in Services

Feroz-Istar opened this issue · 3 comments

I am trying to wirk with Twilio Voice android SDK. When call is connected we are activating audio switch via code audioSwitch.activate();

But it throws

Process: salesken.ai, PID: 14657
java.lang.IllegalStateException
at com.twilio.audioswitch.AudioSwitch.activate(AudioSwitch.kt:208)

What should we do to use it in Android Foreground Service?>

What was the solution to this @Feroz-Istar - we're seeing the exact same thing using

audioSwitch.start { _, selectedAudioDevice ->
    // crashes with IllegalStateException on the next line
    audioSwitch.activate()
}

Can anyone share how they're reproducing this?
I can't reproduce it on my phone, but I see it in our crash analytics.

I can see exception in crash analytics too. But not sure how to reproduce it. This might be happening when audio manager is been used in system applications and when we try to access it via our app. I haven't found any solutions yet