初始化AudioManager:
private static AudioManager audioManager;
实现免提功能方法
protected void setSpeekModle() {
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(!audioManager.isSpeakerphoneOn());
}
需要添加的权限:
<!-- 免提权限 -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>