How to provide customized vibration on specific incoming calls

后端 未结 1 647
清酒与你
清酒与你 2021-02-05 06:28

The program functions like this: the user has a list of phone numbers, for which the cellphone could vibrate upon an incoming call only when no other system-wide application wou

相关标签:
1条回答
  • 2021-02-05 06:42

    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

    0 讨论(0)
提交回复
热议问题