I have an issue with an application: even if ringer mode is RINGER_MODE_VIBRATE
and vibrate setting is VIBRATE_SETTING_ON
, my phone does not vibrate. Here is my code:
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
Note: I am using this code in a broadcast receiver, when the device is ringing (state is TelephonyManager.EXTRA_STATE_RINGING
)
THanks.
did you set on the permission in the manifest file?
<uses-permission android:name="android.permission.VIBRATOR" />