title: Android mute microphone while not in call
body: <p>I want to mute a microphone for quite some time, say a day. However, when a user makes a call or somebody calls, I want to enable the microphone and disable it afterwards. I did this:</p>
  
  <pre><code>AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 
  audioManager.setMicrophoneMute(true);
  </code></pre>
  
  <p>This code works except in a situation after a call. After the call, the microphone is enabled. I suspect that a phone app can enable microphone again and so can other apps. How can I make microphone muted after the call? And is there a way to restrict other apps from enabling microphone?  </p>