复制代码 代码如下:
private static int previousMuteMode = -1;
/**
* 来电静音
*
* @param context
*/
private void toggleRingerMute(Context context)
{
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (previousMuteMode == -1)
{
previousMuteMode = am.getRingerMode();
am.setRingerMode(0);
}
am.setRingerMode(previousMuteMode);
previousMuteMode = -1;
}