简体   繁体   中英

Turn off vibration inside my app

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM