我需要为振动器设置正确的设置,以便我的应用程序尊重设备的声音设置。在下面的代码中,如果振动器关闭(在我的手机上,当我降低音量时,它是音量关闭且振动器关闭的状态,以及音量关闭时振动器打开的状态)。当手机设置为无振动(通过拨打此设备进行验证)时,我仍然让振动器处于打开状态:
AudioManager audioManager = (AudioManager) PingerApplication.getInstance().getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
int vibrationSetting = audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION);
boolean vibrate;
switch(vibrationSetting) {
case AudioManager.VIBRATE_SETTING_ON:
vibrate = true;
break;
case AudioManager.VIBRATE_SETTING_OFF:
vibrate = false;
break;
case AudioManager.VIBRATE_SETTING_ONLY_SILENT:
vibrate = (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE);
break;
default:
vibrate = false;
}
难道我做错了什么?振动设置始终AudioManager.VIBRATE_SETTING_ON