How does Notification.DEFAULT_VIBRATE work? If I set:
notification.defaults |= Notification.DEFAULT_VIBRATE;
what's going to happen?
The documentation is not clear. How can I make the phone vibrating if and only if the vibrate-option for the native sms application or for the call is set to true?
You need to add following permition for enabling vibrate.
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
And for detecting vibrate mode you can use AudioManager's getRingerMode() method
AudioManager audiomanager = (AudioManager)
getSystemService(Context.AUDIO_SERVICE);
switch (audiomanager.getRingerMode()) {
case AudioManager.RINGER_MODE_SILENT:
Log.i("Mode","Silent mode");
break;
case AudioManager.RINGER_MODE_VIBRATE:
Log.i("Mode","Vibrate mode");
break;
case AudioManager.RINGER_MODE_NORMAL:
Log.i("Mode","Normal mode");
break;
}
EDIT
You can check user's vibrate settings of call and notification using following code
Log.i("Setting", ""+audiomanager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER));
Log.i("Setting", ""+audiomanager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION));
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