Turn on speakerphone whenever an outgoing call is made

后端 未结 2 1112
独厮守ぢ
独厮守ぢ 2020-12-16 06:14

My requirement is to turn on speakerphone whenever an outgoing call is initiated. I tried the following code, but it is not working. In fact, speakerphone turns on when in t

2条回答
  •  一整个雨季
    2020-12-16 06:32

    You can set it through programmatically as below :

    AudioManager audioManager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE); 
    audioManager.setMode(AudioManager.MODE_IN_CALL);
    audioManager.setSpeakerphoneOn(true);
    

    But, keep in mind that don't forgot to set speaker off when stop the call:

    audioManager.setSpeakerphoneOn(false);
    

    And, Set permission in manifest:

      
      
    

    This code is working fine for me.hope it will be helpful for you.

提交回复
热议问题