Friday, 28 May 2021

Android - programmatically enable speakers while on call for Huawei

Idea is to enable speakers on the phone while the user is on the call. So first I listen for TelephonyManager.CALL_STATE_OFFHOOK state, then with 2 seconds delay I call following code piece:

val audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager

if (!audioManager.isSpeakerphoneOn) {
      audioManager.mode = AudioManager.MODE_IN_CALL
      audioManager.isSpeakerphoneOn = true
}

This works well on Samsung, but for some reason, does not work on Huawei P20 Pro. Any ideas?



from Android - programmatically enable speakers while on call for Huawei

No comments:

Post a Comment