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 would provide vibration (such as in mute mode). I know that this is somehow against the rules, for that an application should respect the users' settings, but the application is limited to some certain users with this need. I have tried two ways but neither of them are satisfying:
Listen to the telephony state and directly trigger the vibration service with my own pattern (with Vibrator.vibrate()
). This method is effective with no incoming calls yet randomly effective when the phone is in CALL_STATE_RINGING
state and I guess it's because of the conflict with the system-wide application that actually handles the vibration upon incoming call.
Judge whether the cellphone is vibrating upon an incoming call (with AudioManager.shouldVibrate()
), and decide whether to change the vibrate settings (with AudioManager.setRingerMode()
and AudioManager.setVibrateSetting()
). If the vibrate settings are changed by my application, they are to be restored once the cellphone is back to CALL_STATE_IDLE
state. This method, however, is still not functioning sometimes, without any sign of the reason.
I hope that someone could give some advice on this issue. Comments on these two ways or other suggest are welcome.
1) Open up the Contacts app. 2) Find the contact you want to personalise. 3) Open the contact and scroll to the bottom until you get to More options. 4) Select this and then go to Vibration pattern.
Tap any app to bring up a list of your currently installed apps. Tap each app on this list that you want to set up a custom notification vibration pattern for, then press the Pick Apps button at the bottom. Press contains anything for an overview of the options you can choose for the custom notification.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With