title: Android; detect if the Vibrate setting in the device is on or off, esp for the case when it rings but does not vibrate
body: <p>App requirement: To detect when a phone is on <em>Ringing mode with the Vibrate Setting being OFF</em> 
  <strong><em>so the problem comes down to : detect whether the Vibrate Setting is OFF or ON</em></strong></p>
  
  <p>Relevant information:</p>
  
  <p>To start with, 
  <a href="http://developer.android.com/reference/android/os/Vibrator.html" rel="nofollow noreferrer">Vibrator</a> has no method like <code>isVibratorModeOn()</code>  and the 
  <a href="http://developer.android.com/reference/android/media/AudioManager.html#VIBRATE_SETTING_CHANGED_ACTION" rel="nofollow noreferrer">Flags related to Vibrate</a> and <a href="http://developer.android.com/reference/android/media/AudioManager.html#EXTRA_VIBRATE_TYPE" rel="nofollow noreferrer">EXTRA_VIBRATE_...</a>  are all marked deprecated with:</p>
  
  <blockquote>
    <p>This constant was deprecated in API level 16. Applications should
    maintain their own vibrate policy based on current ringer mode that
    can be queried via getRingerMode().  </p>
  </blockquote>
  
  <p>But under <a href="http://developer.android.com/reference/android/media/AudioManager.html#getRingerMode()" rel="nofollow noreferrer">getRingerMode()</a>, we won't exactly know if the vibrate setting is off or not with <a href="http://developer.android.com/reference/android/media/AudioManager.html#RINGER_MODE_NORMAL" rel="nofollow noreferrer">RINGER_MODE_NORMAL</a>;  </p>
  
  <blockquote>
    <p>It will vibrate if the vibrate setting is on.  </p>
  </blockquote>
  
  <p>Now the <a href="http://developer.android.com/reference/android/media/AudioManager.html#getVibrateSetting(int)" rel="nofollow noreferrer">getVibrateSetting()</a> is also deprecated.</p>
  
  <p>Code which works for detecting the <code>RINGER_MODE</code> on *most devices and o.s. versions including <a href="https://developer.android.com/preview/download.html" rel="nofollow noreferrer">Android M on Nexus 6</a>:</p>
  
  <pre><code> if(audioManager.getRingerMode()!=AudioManager.RINGER_MODE_SILENT){
              if (audioManager.getStreamVolume(AudioManager.STREAM_RING) != 0) {  
  </code></pre>
  
  <p>*Exception: Nexus 5 - 5.1.1, probably for all Lollipop versions  </p>
  
  <p>I feel its very surprising if this has been missed or i've made the big(gest) silly mistake by missing something obvious. Hopefully, this isn't a waste of your time.</p>
  
  <p>Here's more to explain the problem:<br>
  <code>RINGER_MODE_SILENT</code>scenario covered:
  <a href="https://i.stack.imgur.com/iCXiB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iCXiB.jpg" alt="Scenario Covered - ringer silent mode"></a>  </p>
  
  <p><code>RINGER_MODE_VIBRATE</code> scenario covered:
  <a href="https://i.stack.imgur.com/1QKhO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1QKhO.jpg" alt="Scenario Covered - ringer vibrate mode"></a></p>
  
  <p><strong><em>DETECTING THIS IS THE PROBLEM:</em></strong><br>
  <a href="https://i.stack.imgur.com/GDfkV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GDfkV.jpg" alt="Problem senario - ringer volume high, vibrate setting off"></a></p>
  
  <p>Screenshot crops from Android M, Nexus 6  </p>