Android 中时钟应用程序启动闹钟时触发代码

发布于 2024-10-09 17:42:21 字数 128 浏览 0 评论 0原文

当时钟应用程序中的闹钟执行时,是否有办法触发一些代码?我读到了有关警报管理器的信息,但它仅用于创建您自己的警报。

我想您永远无法确定设备上是否存在时钟应用程序。但如果确实如此,我希望得到通知。

/约翰内斯兄弟

Is there anyway to trigger some code when the Alarm in the clock-application is executed? I read about the Alarm Manager but its only for creating your own alarms.

I guess you will never be sure if the clock-application exists on the device. But if it does I would like to get notified.

/Br Johannes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哑剧 2024-10-16 17:42:21

警告:您正在尝试获取有关时钟状态的通知。此应用程序不是官方 Android SDK 的一部分:Google 不支持(或推荐)以下解决方案,如有更改,恕不另行通知。

查看 DeskClock(AlarmClock 的新名称)的源代码。具体看一下它的 AndroidManifest.xml

它似乎接收到 com.android.deskclock.ALARM_ALERT

<receiver android:name="AlarmReceiver">
    <intent-filter>
        <action android:name="com.android.deskclock.ALARM_ALERT" />
        <action android:name="alarm_killed" />
        <action android:name="cancel_snooze" />
    </intent-filter>
</receiver>

尝试在您的应用程序中注册此接收器。

Warning: You are trying to get a notification about a Clock's state. This app is not part of official Android SDK: the solution below is not supported (or recommended) by Google and subject to change without notice.

Take a look at the source code od DeskClock (a new name for AlarmClock). Specifically take a look at it's AndroidManifest.xml.

It seems that it receives com.android.deskclock.ALARM_ALERT:

<receiver android:name="AlarmReceiver">
    <intent-filter>
        <action android:name="com.android.deskclock.ALARM_ALERT" />
        <action android:name="alarm_killed" />
        <action android:name="cancel_snooze" />
    </intent-filter>
</receiver>

Try registering this receiver in your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文