how can I detect whether the android phone in Silent mode programmatically
Use the getRingerMode()
method in AudioManager
.
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;
}