Audiomanager Speaker not working

这一生的挚爱 提交于 2019-12-06 03:17:57

Hi read android developer article

https://developer.android.com/reference/android/media/AudioManager.html

explain it clearly

you need to set Permission: MODIFY_AUDIO_SETTINGS in manifest

add this line in manifest

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

I found that setMode() (the current mode) before setSpeakerphoneOn() fixes the error on the logcat:

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

1.setSpeakerphoneOn() is only working on setMode(AudioManager.MDOE_IN_CALL);

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