android / media-samples

Multiple samples showing the best practices in media APIs on Android (audio, video, etc.).
Apache License 2.0
1.27k stars 740 forks source link

AudioManager returns wrong RingerMode #67

Open JitainSharma opened 4 years ago

JitainSharma commented 4 years ago

Android OS : 6.0 Device : Moto-G 2nd Gen

While using the AudioManager API to get the Phone ringer mode, the value return only for the mute/sleep is wrong, it returns the RINGER_MODE_VIBRATE instead of RINGER_MODE_SILENT on Android 6, where as the values returned correctly on Android 9 and 10.

Code is: 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;}

Ringer mode are set through phone sound/mute/vibrate profiles. How to get correct value for silent mode?