How To Turnon Speaker On a Phone Call In Android 13

99 Views Asked by At

this piece of code not work on android 13 maybe someone know how to make it work on android 13?

      TelephonyManager.CALL_STATE_OFFHOOK -> {
                // Call answered (in progress) Handle call answered state here
                Timber.d("onPhoneState: CALL_STATE_OFFHOOK")
                val mainActivity = getMainActivity()
                val audioManager = mainActivity.getSystemService(Context.AUDIO_SERVICE) as AudioManager?
                audioManager?.mode = AudioManager.MODE_IN_CALL
                audioManager?.isSpeakerphoneOn = true
            }

To turnon speaker when phonecall is in progress via kotlin

1

There are 1 best solutions below

0
Eli On

In Android 10 and above: Direct control over the speakerphone during calls is restricted for security reasons. Consider these approaches:

  1. Default speakerphone: Set the speakerphone to be on by default when initiating calls.
  2. Accessibility service: Use an accessibility service to toggle the speakerphone, but this requires user consent and activation.