如何静音声音和振动在Android 5.0以上版本的所有通知? [英] How to mute sound and vibration for all notifications in Android 5.0+?

查看:1018
本文介绍了如何静音声音和振动在Android 5.0以上版本的所有通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用的声音和振动对所有传入的通知。如果电话震动被关掉,嫌我不介意。但对于电话用户的音量设置不应该被感动。

I would like to disable sound and vibration for all incoming notifications. I don't mind if phone call vibration gets switched off, too. But the users volume settings for phone calls shouldn't be touched.

感谢 AudioManager ,静音通知的声音很容易

Thanks to the AudioManager, muting the sound of notifications is easy:

audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);

禁用通知的振动,但是,更难于预期。

Disabling the vibration of notifications, however, is harder than expected.

该AudioManager有pcated方法振动设置此德$ P $:

The AudioManager has this deprecated method for vibration settings:

audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF)

然而,这似乎有我的Andr​​oid 5.0设备上没有影响,我找不到任何的替代品。 (

This, however, seems to have no effect on my Android 5.0 device and I can't find any alternatives. :(

我知道,棒棒堂推出了周围的东西优先模式但我不想与模式捣鼓。切换模式将可能有一些其他的副作用(基于用户优先preferences)

I know that Lollipop has introduced the stuff around "Priority Mode" but I do not want to fiddle with modes. Switching the mode would probably have some other side-effect (based on the users priority preferences).

任何想法如何忽略通知声音和振动在Android 5.0 +?

Any ideas how to mute notification sound and vibration on Android 5.0+?

推荐答案

由于没有人想出了一个解决方案,我会回答我的问题。

Since nobody came up with a solution, I'm going to answer my own question.

这似乎是有真现的方式来实现我想要的东西,至少在最新的Andr​​oid版本。所以,我最后做以下的解决方法:

It seems that there is really now way to achieve what I wanted, at least with the latest Android versions. So I ended up doing the following ugly workaround:

我现在通过的 RINGER_MODE_SILENT 也听通过一个BroadcastReceiver的来电。一旦检测到来电时,RingerMode被收归旗下previous状态。这有效地导致了我想实现的功能。

I'm now muting that whole phone (incoming phone calls and notifications) via RINGER_MODE_SILENT but also listen for incoming phone calls via a BroadcastReceiver. As soon as an incoming call is detected, the RingerMode gets reverted to its previous state. This effectively leads to the functionality I wanted to achieve.

我,但是,这种解决方法非常不满。

I'm, however, extremely unsatisfied with this workaround.

这篇关于如何静音声音和振动在Android 5.0以上版本的所有通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆