如何仅使来电铃声静音而不使短信静音,并且仅使短信静音?
我尝试像使用audioManager.setStreamVolume()
audioManager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
switch (mode){
case CALLS:
audioManager.setStreamVolume(AudioManager.STREAM_RING,AudioManager.ADJUST_MUTE,0);
break;
case MSGS:
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION,AudioManager.ADJUST_MUTE,0);
break;
case CALLS_AND_MSGS:
audioManager.setStreamVolume(AudioManager.STREAM_RING,AudioManager.ADJUST_MUTE,0);
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION,AudioManager.ADJUST_MUTE,0);
break;
}
在所有情况下,来电和短信均处于静音状态
答案 0 :(得分:0)
您需要使用以下代码行
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);