Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mute microphone programmatically in android [duplicate]

Tags:

android

I want to mute my microphone programmatically ,i tried the following code but it is use full.

micro_phone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
                audioManager.setMode(AudioManager.MODE_IN_CALL);
                if (audioManager.isMicrophoneMute() == false) {
                    audioManager.setMicrophoneMute(true);

                } else {
                    audioManager.setMicrophoneMute(false);

                }
like image 317
user6264 Avatar asked Sep 28 '16 13:09

user6264


1 Answers

Check if you added permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" , it is mandatory for changing audio settings

like image 160
Alex Shutov Avatar answered Nov 18 '22 23:11

Alex Shutov