This is my code to mute/unmute phone. But I would like to check if phone is alreay on mute and if is not then i will mute it. If is in vibrate then i will make it normal.
Can i check this states somehow?
public void changeRingerMode(Context context){ AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); /** * To Enable silent mode..... */ audio.setRingerMode(AudioManager.RINGER_MODE_SILENT); /** * To Enable Ringer mode..... */ audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL); }
The Silent Mode icon looks like a speaker with a line through it or a speaker with circle and a line superimposed over it. When the Silent Mode is disabled, only a speaker icon appears.
To turn off silent mode: Tap the upper part of the Volume key to select the required ring volume. If vibration is turned on, silent mode isn't turned on when you tap the Volume key. See how to turn vibration on or off.
try this:
switch( audio.getRingerMode() ){ case AudioManager.RINGER_MODE_NORMAL: break; case AudioManager.RINGER_MODE_SILENT: break; case AudioManager.RINGER_MODE_VIBRATE: break; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With