我试图在我的 Android 应用程序中将我的麦克风静音
audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setMicrophoneMute(true);
我还在 list 中添加了权限
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
但是,当我对我的应用程序说话时,日志会准确地返回我所说的内容,这意味着麦克风没有静音。
甚至日志都告诉我麦克风应该静音。这:
Log.d("Muted ? : ", String.valueOf(audioManager.isMicrophoneMute()));
显示此日志:
Muted ? : true
我真的不知道可能是什么问题。 你知道吗?
最佳答案
我也试过,我认为问题出在所有设备上,但有些设备可以将其麦克风静音,我尝试了这个答案的相同解决方案:
setMicrophoneMute(boolean) doesn't work on some devices
i simulate a press on mute button on the handsfree kit . it worked for me hope it will help you too here is the code:
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT,new KeyEvent(KeyEvent.ACTION_UP,KeyEvent.KEYCODE_HEADSETHOOK));
getBaseContext().sendOrderedBroadcast(buttonUp,"android.permission.CALL_PRIVILEGED");
关于android - 无法设置麦克风静音 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30759645/