Vibrate settings on Android 2.2

对着背影说爱祢 提交于 2019-11-30 02:32:25

I had to mess with these settings myself when some application messed up my Nexus One's individual settings. Here they are:

Always vibrate on ring:

setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);

Never vibrate on ring:

setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);

Vibrate on ring in silent only:

setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT);

Always vibrate on notify:

setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ON);

Never vibrate on notify:

setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);

Vibrate on notify in silent only:

setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ONLY_SILENT);

Change ringer mode:

AudioManager.setRingerMode(RINGER_MODE_NORMAL); AudioManager.setRingerMode(RINGER_MODE_SILENT); AudioManager.setRingerMode(RINGER_MODE_VIBRATE);

Vibrate settings are independent of ringer settings. Confusion ensues.

LuTHieR

Ok, I think I finally fixed it.
I looked at the source code of the com.android.settings.Settings class and copied part of the methods that enable and disable vibrate:
https://android.googlesource.com/platform/packages/apps/Settings/+/master/src/com/android/settings/SoundSettings.java

Thank you anyway magaio, you pointed me in the right direction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!