This is my code, when I run it, it switches between the main speaker and the phone speaker (that is, one is activated and the other is deactivated). What should I do to activate two speakers at the same time?
if (isSpeakerOn) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
audioManager.mode = AudioManager.MODE_IN_COMMUNICATION
} else {
audioManager.isSpeakerphoneOn = false
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
audioManager.mode = AudioManager.MODE_NORMAL
} else {
audioManager.isSpeakerphoneOn = true
}
}