安卓,静音模式通知

编程入门 行业动态 更新时间:2024-10-20 03:31:31
本文介绍了安卓,静音模式通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的Andr​​oid应用程序,我需要知道,每当用户在手机的选择模式(当您按住了一段时间的电源按钮时出现的一个),并推动了静音模式按钮。我发现,飞行模式被链接到 ACTION_AIRPLANE_MODE_CHANGED 。但是,我找不到任何操作事件为静音模式按钮?

In my android app I need to know, whenever the user is in Phone options mode (the one that appears when you hold down the power button for a while), and pushes the 'Silent mode' button. I have found that Airplane mode is linked to the ACTION_AIRPLANE_MODE_CHANGED. But I can not find any action event for the 'Silent mode' button?

推荐答案

在 AudioManager 提供了 getRingerMode()方法,它可以用于确定当前状态。 你的情况,你必须查询 AudioManager.RINGER_MODE_SILENT 返回值,所以像

The AudioManager provides a getRingerMode() method which can be used to determine the current state. In your case you have to query the returned value for AudioManager.RINGER_MODE_SILENT, so something like

AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); if (am.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { // do something neat here }

在与组合AudioManager的 RINGER_MODE_CHANGED_ACTION 这应该为你工作。

In combination with AudioManager's RINGER_MODE_CHANGED_ACTION this should work for you

更多推荐

安卓,静音模式通知

本文发布于:2023-11-27 08:05:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静音   模式   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!