iForests
iForests

Reputation: 6949

Why AudioManager.getRingerMode() return only 3 modes?

According to the document,

getRingerMode() returns the current ringtone mode, one of RINGER_MODE_NORMAL, RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE.

But there should be 4 modes, right?

Sound ON, Vibrate OFF: How can I know that the setting is this one?
Sound ON, Vibrate ON: RINGER_MODE_NORMAL
Sound OFF, Vibrate OFF: RINGER_MODE_SILENT
Sound OFF, Vibrate ON: RINGER_MODE_VIBRATE

Please help me out. Thank you.

enter image description here

Upvotes: 4

Views: 2420

Answers (2)

诸葛铁牛
诸葛铁牛

Reputation: 11

if (Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) == 1)
{    
    return true;
}
else if (Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) == 0)
{
    return false;
}

I have try, useful

Upvotes: 0

Vigneshwaran Murugesan
Vigneshwaran Murugesan

Reputation: 757

You can set the ringer method to RINGER_MODER_NORMAL (Sound and vibrate on) and separately set the vibrate setting to VIBRATE_SETTING_OFF(turn off vibrate completely) OR VIBRATE_SETTING_ONLY_SILENT.(Vibrate only if the mode is silent) as below:

To turn off ringtone vibrations:

setVibrateSetting (AudioManager.VIBRATE_TYPE_RINGER,AudioManager.VIBRATE_SETTING_OFF)

To turn off notification vibrations:

setVibrateSetting (AudioManager.VIBRATE_TYPE_NOTIFICATION,AudioManager.VIBRATE_SETTING_OFF)

UPDATE:To get the status of the current audio mode by

   if(getRingerMode ()==AudioManager.RINGER_MODE_NORMAL)
    {    if((getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER))==AudioManager.AudioManager.VIBRATE_SETTING_OFF){    
        Log.d("Ringer Mode is":"ring with no vibraion")
        }
    else{
    Log.d("Ringer Mode is":"ring with vibraion")
    }

    else if(getRingerMode ()==AudioManager.RINGER_MODE_SILENT){

if((getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER))==AudioManager.AudioManager.VIBRATE_SETTING_OFF){    
        Log.d("Ringer Mode is":"Silent with no vibraion")
        }
    else{
    Log.d("Ringer Mode is":"Silent with vibraion")
    }
    }
else{
 Log.d("Ringer Mode is":"Silent with vibraion")

}

In the Docs it is said that it RINGER_MODE_SILENT mode will override the vibrate setting.

PS: According to DOC get/setVibrateSetting()**method was **deprecated in API level 16. Note: I havent Tested the code.

Upvotes: 2

Related Questions