title: Ringer mode change listener Broadcast receiver?
body: <pre><code>AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
  
  switch (am.getRingerMode()) {
      case AudioManager.RINGER_MODE_SILENT:
          Log.i("MyApp","Silent mode");
      break;
  
      case AudioManager.RINGER_MODE_VIBRATE:
          Log.i("MyApp","Vibrate mode");
      break;
  
      case AudioManager.RINGER_MODE_NORMAL:
          Log.i("MyApp","Normal mode");
      break;
  }
  </code></pre>
  
  <p>From the code above I can get the ringer mode. What I would liek to do is listen the ringer mode changes and call a function. </p>
  
  <p>What I have been told is that I can register the AudioManager. RINGER_MODE_CHANGED_ACTION and listen the change intent in broadcastreceiver onReceive method. It sounds clear. But I am new to android and really dont know how to write it. Is there any one can just write a piece of code and show how exactly it works instead of saying use this or that :) Thank you</p>