title: Android AudioManager, after mute can NOT unmute it
body: <p>I build a simple video player in my App.</p>
  
  <p>I only want to play the audio via the headset not speakers.</p>
  
  <p>so, I do the following </p>
  
  <p><strong>onCreate</strong></p>
  
  <pre><code>AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  </code></pre>
  
  <p>....</p>
  
  <pre><code>@SuppressWarnings("deprecation")
  private void checkJack() {
      if(Constants.HEADSET_ONLY &amp;&amp; !musicReceiverStarted) {
          Log.v(TAG + " | AudioManager checkJack", "Running checkJack()");
          audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
          try 
           {
  
              if(!audio.isWiredHeadsetOn()) {
                  Log.v(TAG + " | AudioManager checkJack", "Headset is unplugged");
                  audio.setStreamMute(AudioManager.STREAM_MUSIC, true); // Mute
                  Toast.makeText(DuplicatedPlayerActivity.this, "Please plug in your headset to enjoy the sound.", Toast.LENGTH_SHORT).show();
              }
              else {
                  Log.v(TAG + " | AudioManager checkJack", "Headset is plugged");
                  audio.setStreamMute(AudioManager.STREAM_MUSIC, false); // UnMute
              }
          } 
          catch (Exception e) { e.printStackTrace(); }
      }
  }//end checkJack
  </code></pre>
  
  <p>Then I have a receiver :</p>
  
  <pre><code>private class MusicIntentReceiver extends BroadcastReceiver {
      @Override 
      public void onReceive(Context context, Intent intent) {
  
          if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
  
              musicReceiverStarted = true;
              audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
              int state = intent.getIntExtra("state", -1);
              switch (state) {
  
                  case 0:
                      Log.d(TAG + " | AudioManager", "Headset is unplugged");
                      audio.setStreamMute(AudioManager.STREAM_MUSIC, true); // Mute
                      Toast.makeText(DuplicatedPlayerActivity.this, "Please plug in your headset to enjoy the sound.", Toast.LENGTH_SHORT).show();
                      break;
  
                  case 1:
                      Log.d(TAG + " | AudioManager", "Headset is plugged");
                      audio.setStreamMute(AudioManager.STREAM_MUSIC, false); // UnMute
                      break;
  
                  default:
                      Log.d(TAG + " | AudioManager", "I have no idea what the headset state is");
                      audio.setStreamMute(AudioManager.STREAM_MUSIC, true); // Mute
                      Toast.makeText(DuplicatedPlayerActivity.this, "Please plug in your headset to enjoy the sound.", Toast.LENGTH_SHORT).show();
              }
          }//end if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG))
      }//end onReceive
  }//end MusicIntentReceiver
  </code></pre>
  
  <p>Now the problem is: Both function runs correct. but After the Audio has beeb muted in the checkJack();  It wont unmute in MusicIntentReceiver();</p>
  
  <p>Also the MusicIntentReceiver() only get execute when there is a jack state changed. so I can not use it for mute the audio for the first time, because it will never get execute.</p>
  
  <p>Any advice.</p>