tags:

views:

604

answers:

2

Hi All,
Can anyone provide me a code snippet to identify whether the phone is in Silent mode or not.

I am using Android 1.5. I tried by using "android.provider.Settings.ACTION_SOUND_SETTINGS". It is not working.

Thanks in Advance...

With Regards,
Raghavendra K.

+5  A: 

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;
}
Dave Webb
Hi Dave is there any way to toggle Silent as well as vibrating mode programatically.
Vinayak.B
`setRingerMode()` in `AudioManager` allows you to change the ringer mode.
Dave Webb
Hi Dave I can able to handle the silent mode using am.setRingerMode(AudioManager.RINGER_MODE_SILENT);but handling Vibrating mode using AudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF); is not working any clue
Vinayak.B
What is it that you're trying to do exactly? I don't think `setVibrateSettings()` does what you think it does.
Dave Webb
Thanks Dave I got it too..
Vinayak.B
Thank you very much Dave.
Raghavendra
A: 

i need to change my profile to silent or pager or ringing automatically based on the geolocation can any of u helpme out damn urgent

Vasanthi Naidu