Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

android - setMicrophoneMute(boolean) doesn't work on some devices

I couldn't find any related post here (but other small posts on the internet), so here it is:

AudioManager.setMicrophoneMute(boolean) doesn't do anything on some particular devices that I tested with: Google Nexus S, Samsung Galaxy S and Motorola Milestone. On any other device it works well.

It even maintains its "state" and returns a boolean as if it got mutedunmuted, but it doesn't mute - microphone continues to record - both in GSM call and in AudioRecord programmatic recording. There is no indicative log message.

I also messed with permissions (android.permission.MODIFY_AUDIO_SETTINGS, android.permission.RECORD_AUDIO), nothing new here.

Did anyone else encounter that? Does anyone have a workaround or a magic solution? If I use AudioRecord I just implement my own "mute" for these devices - I don't pass on the recorded buffers. But it can't help me with muting the mic in a GSM call, which I need.

Thanks

---------------- Update ----------------

See below.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Hi i had the same problem i wanted to simulate incoming call screen. and within that screen a button that perform mute, and the AudioManager.setMicrophoneMute(boolean) worked on most phones but not on all of them. i found a way to get around it. 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");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...