i have implemented the IncallService dialer replacement with my own UI and trying to add the basic dialer functionalities. Most of them ( Mute , Play DTMF , Hold) work except setting loud speaker. i tried the below but getting a error "do not have using speaker authority in call". I'm checking on both android 7 and 8 phones.
permission added :"android.permission.MODIFY_AUDIO_SETTINGS"
val audioManager =
applicationContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager
// get original mode
val originalMode = audioManager.mode
audioManager.mode = AudioManager.MODE_IN_CALL
// change mute
val state = !audioManager.isSpeakerphoneOn
// Loggable.log.debug(LOG_TAG, "Speaker state is " + state)
audioManager.isSpeakerphoneOn = state
// set mode back
audioManager.mode = originalMode