简体   繁体   English

Android:如何在Lollipop中将响铃模式设置为静音

[英]Android : How to set ringing mode to silent in Lollipop

Prior Lollipop i was using below code to Mute Ringing Tone 以前的棒棒糖我正在使用以下代码使铃声静音

// Mute Ringtone

AudioManager amanager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
amanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);

It is not working anyomore on devices runnning on lollipop. 它在棒棒糖上运行的设备上不再起作用。 It although sets the priority mode but do not silence at all. 尽管设置了优先模式,但完全不静音。 Any help will be appreciated. 任何帮助将不胜感激。

setRingerMode()

Sets the ringer mode. 设置铃声模式。

Silent mode will mute the volume and will not vibrate. 静音模式将使音量静音并且不会振动。 Vibrate mode will mute the volume and vibrate. 振动模式将使音量静音并振动。 Normal mode will be audible and may vibrate according to user settings. 普通模式将是可听见的,并可能会根据用户设置而振动。

This method has no effect if the device implements a fixed volume policy as indicated by "isVolumeFixed()". 如果设备执行“ isVolumeFixed()”指示的固定音量策略,则此方法无效。

as mentioned in :- http://developer.android.com/reference/android/media/AudioManager.html#setRingerMode(int) 如: -http : //developer.android.com/reference/android/media/AudioManager.html#setRingerMode(int)中所述

and

http://developer.android.com/reference/android/media/AudioManager.html#isVolumeFixed() http://developer.android.com/reference/android/media/AudioManager.html#isV​​olumeFixed()

But this function works on my nexus 4 running android 5.0. 但是此功能适用于运行Android 5.0的我的nexus 4。 However, call ringtone does not get silent immediately but after completion of playing once cycle of tone in which mute call ringtone button is pressed and this code is invoked. 但是,呼叫铃声不会立即静音,而是在播放完一次音频周期后(按下静音呼叫铃声按钮并调用此代码)会使其静音。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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