문제

I'm developing an app and need to completely turn off vibration alerts when my app is running. For example if an call comes in while my app is open I don't want to have the vibration alert, the same with emails and anyother notification.

So I've been googling around for a while and found this:

AudioManager amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
amanager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER,AudioManager.VIBRATE_SETTING_OFF);

The problem is that this method is deprecated. And I can't find an other way of doing this.

The minSdkVersion = 9 and targetSdkVersion = 17.

Any idea?

Thanks!!

도움이 되었습니까?

해결책

See AudioManager RingerMode

It should now be

AudioManager amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
amanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top