문제

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" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top