可以参考下这个:
希望情景模式为静音模式时,来电可以震动
[SOLUTION]
首先修改Silent这个模式下,震动的默认值,即在AudioProfileManager.java 的getDefaultState()中将DEFAULT_VIBRATION_SILENT设为true;
然后在AudioService.java的shouldVibrate()中 如下case AudioManager.VIBRATE_SETTING_ON的地方改成true:
public boolean shouldVibrate(int vibrateType) {
if (!mHasVibrator) return false;
switch (getVibrateSetting(vibrateType)) {
case AudioManager.VIBRATE_SETTING_ON:
// return getRingerMode() != AudioManager.RINGER_MODE_SILENT;
return true; //Modify this line
case AudioManager.VIBRATE_SETTING_ONLY_SILENT:
return getRingerMode() == AudioManager.RINGER_MODE_VIBRATE;
case AudioManager.VIBRATE_SETTING_OFF:
// return false, even for incoming calls
return false;
default:
return false;
}
}