当前位置: 编程技术>移动开发
android实现来电静音示例(监听来电)
来源: 互联网 发布时间:2014-10-24
本文导语: 代码如下:private static int previousMuteMode = -1; /** * 来电静音 * * @param context */private void toggleRingerMute(Context context){ AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (previousMuteMode == -1) { prev...
代码如下:
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;
}