How to provide customized vibration on specific incoming calls

若如初见. 提交于 2019-12-03 01:25:45

You need to play with two settings in order for your phone to vibrate. The first one is the sound mode which needs to be set by using AufioManager:

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(targetSoundMode);

The second part is not properly documented and I believe this is the missing part of your code:

String VIBRATE_IN_SILENT_SETTING_NAME = "vibrate_in_silent";
Settings.System.putInt(getContentResolver(), VIBRATE_IN_SILENT_SETTING_NAME, 1);

use 1 to turn vibrate on and 0 to turn vibrate off.

to fully understand how you should work with vibrate settings and mode take a look at the following link: http://hi-android.info/src/com/android/settings/SoundSettings.java.html

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