android实现来电静音示例(监听来电)
程序员文章站
2024-02-03 15:05:58
复制代码 代码如下:private static int previousmutemode = -1;
/** * 来电静音 * * @p...
复制代码 代码如下:
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;
}