user1982396
user1982396

Reputation:

How to read vibration setting android?

Is it possible to read vibration setting for ringing?

I'm getting vibration state by using:

if(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)
    {
        //silent
    }
    else if(audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE)
    {
        ringPhone(callerRing);
        vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        long[] pattern = { 0, 1000, 1000 };
        vibrator.vibrate(pattern, 0);
    }
    else if(audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL)
    {
        ringPhone(callerRing);
    }

In case of RINGER_MODE_NORMAL, I want to get setting for vibration on an incoming call.

In Android system settings, there is an option inside Sound, "Vibrate on ring". I need to read this option inability.

Any help will be appreciated.

Thanks

Upvotes: 4

Views: 1260

Answers (1)

yshahak
yshahak

Reputation: 5096

A little late, but I need to do the same and solve it by:

public static boolean checkVibreationIsOn(Context context) {
    return (1 == Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0)); //vibrate on
}

Upvotes: 1

Related Questions