获取系统响铃和震动:
通过AudioManager的getRingerMode获取铃声模式:
/**
* Returns the current ringtone mode.
*
* @return The current ringtone mode, one of {@link #RINGER_MODE_NORMAL},
* {@link #RINGER_MODE_SILENT}, or {@link #RINGER_MODE_VIBRATE}.
* @see #setRingerMode(int)
*/
public int getRingerMode() {
//... ...
}
RING_MODE_NORMAL:一般模式,即响铃模式,会震动如果系统震动开了的话。
RING_MODE_VIBRATE:震动模式,只震动,不响铃。
RING_MODE_SILENT:不震动也不响铃。
通过AudioManager的getVibrateSetting(int vibrateType)/**
* Returns whether the user's vibrate setting for a vibrate type.
* <p>
* This shouldn't be needed by most clients that want to vibrate, instead
* see {@link #shouldVibrate(int)}.
*
* @param vibrateType The type of vibrate. One of
* {@link #VIBRATE_TYPE_NOTIFICATION} or
* {@link #VIBRATE_TYPE_RINGER}.
* @return The vibrate setting, one of {@link #VIBRATE_SETTING_ON},
* {@link #VIBRATE_SETTING_OFF}, or
* {@link #VIBRATE_SETTING_ONLY_SILENT}.
* @see #setVibrateSetting(int, int)
* @see #shouldVibrate(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public int getVibrateSetting(int vibrateType) {
/**
* Returns whether the user's vibrate setting for a vibrate type.
* <p>
* This shouldn't be needed by most clients that want to vibrate, instead
* see {@link #shouldVibrate(int)}.
*
* @param vibrateType The type of vibrate. One of
* {@link #VIBRATE_TYPE_NOTIFICATION} or
* {@link #VIBRATE_TYPE_RINGER}.
* @return The vibrate setting, one of {@link #VIBRATE_SETTING_ON},
* {@link #VIBRATE_SETTING_OFF}, or
* {@link #VIBRATE_SETTING_ONLY_SILENT}.
* @see #setVibrateSetting(int, int)
* @see #shouldVibrate(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public int getVibrateSetting(int vibrateType) {
//......
}
VIBRATE_TYPE_RINGER:获取铃声的震动设置
VIBRATE_TYPE_NOTIFICATION:获取通知的震动设置
VIBRATE_SETTING_ON:表示震动开启
VIBRATE_SETTING_OFF:表示震动关闭
VIBRATE_SETTING_ONLY_SILENT:建议只在震动模式下震动,即响铃模式下不震动。
不够这方法已经被抛弃了,因为它建议在获取铃声模式时,应用自己有一个震动设置,就是自己另设一个值。
Notification铃声设置:
/**
* Specifies which values should be taken from the defaults.
* <p>
* To set, OR the desired from {@link #DEFAULT_SOUND},
* {@link #DEFAULT_VIBRATE}, {@link #DEFAULT_LIGHTS}. For all default
* values, use {@link #DEFAULT_ALL}.
* </p>
*/
public int defaults;
notification.defaults |= Notification.DEFAULT_VIBRATE;//就是用置1的方式,一个int,用于多个标志,分别是声音标志,震动标志,闪光标志,和前面标志所有都默认标志。
Uri notification.sound;
long[] notification.vibrate;