Turn on speakerphone whenever an outgoing call is made

穿精又带淫゛_ 提交于 2019-11-29 02:24: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:

  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

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

Mark Semsel

A similar question was asked and answered here.

I think the answer may be in your project's AndroidManifest.xml. Try adding:

uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"

to your manifest, which will allow your app to modify the device's audio settings.
You will also need to change your audioManager mode to MODE_IN_CALL:

audioManager.setMode(AudioManager.MODE_IN_CALL)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!