Reputation: 2817
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
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