检测用户何时设置闹钟 Android
当设备检测到用户设置了警报时,我尝试执行操作。
有谁知道我如何在代码中做到这一点?将不胜感激任何建议。
谢谢
I am trying to execute an action when the device detects that the alarm is set by the user.
Does anyone know how I can go about doing this in code? Would appreciate any advice.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用户没有执行统一的“操作”来设置警报。将其称为“警报”甚至可能都不正确,因为警报只是另一个应用程序。用户可以使用 Android 附带的库存闹钟(我猜是在时钟应用程序中?),手机制造商可能已将自己的闹钟应用程序与手机捆绑在一起,或者用户可能已从 Android 下载了第 3 方闹钟应用程序市场。
我猜想所有这些不同的应用程序唯一的共同点是它们以某种方式可以使用
AlarmManager
类来控制闹钟何时响起。但我不认为这是你可以听的东西(除了闹钟应用程序之外,还有许多其他应用程序也使用 AlarmManager)。There isn't a unified "action" the user performs that will set the alarm. It would probably not even be correct to refer to it as "the alarm", because the alarm is just another application. The user can be using the stock alarm shipping with Android (in the Clock application, I would guess?), the phone manufacturer might have bundled its own alarm app with the phone, or the user might have downloaded a 3rd party alarm application from Android Market.
I would guess that the only thing all those different apps could have in common, is that they in some way could use the
AlarmManager
class to control when the alarm should go off. But I don't think this is something you can listen to (and it is also lots of other apps other than alarm apps that also use the AlarmManager).