umerk44
umerk44

Reputation: 2817

Android mute/umute not working properly on asus device

I am using AudioManager to mute unmute on Asus memopad 10. I can mute the device but i can't unmute it back. If i use some other application which uses microphone it also doesn't work there. Then i have to restart the device than it start working.

Edti : Mute code

_audioManager.setMicrophoneMute(mute);

Upvotes: 0

Views: 180

Answers (1)

user2320244
user2320244

Reputation:

Suppose this is the scenario, where you set the microphone to mute using a boolean and then use a button on screen to unmute it.

Boolean mute = true;
        final AudioManager myAudio;

        myAudio=(AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
        myAudio.setMicrophoneMute(mute);
        Button unmute = (Button)findViewById(R.id.unm);
        unmute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myAudio.setMicrophoneMute(false);
            }
        });

Another scenario where you use the same button to mute or unmute :

public Boolean mute = true;
            final AudioManager myAudio;

            myAudio=(AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

            Button unmute = (Button)findViewById(R.id.unm);
            unmute.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    myAudio.setMicrophoneMute(mute);
                if(mute=true){

                    mute=false;

                }
            else{

              mute=true;

                 }
                }
            });

Now everytime,the button

Upvotes: 1

Related Questions