Forcing MediaRecorder to use internal microphone

南笙酒味 提交于 2019-11-30 23:26:37

Unfortunately, you're trying to go against Android's audio management, this is, the system selects input device depending on selected audio source and, when the headset is pluged in, input, for MIC audio source, is switched to the headset. You can confirm this checking logcat's AudioPolicyManager's related messages.

My suggestion would be playing with different audio sources to trick the system. I would recommend using CAMCORDER or, at least, try VOICE_RECOGNITION or VOICE_COMMUNICATION.

Main problem with CAMCORDER is that it can be using multimedia microphone, this is, the one at the back of the device. More in detail, I would suggest following procedure:

  1. Listen for ACTION_HEADSET_PLUG Intent.
  2. When you receive the intent, try to switch audio source to CAMCORDER.
  3. CAMCORDER audio source is selected depending on active camera so you can try to force front camera usage (and, then, front internal mic) through MediaREcorder's setCamera

Hope this helps

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