简体   繁体   English

我该如何为Android应用注册TIME_TICK事件广播接收器,即使该应用是否正在运行

[英]how can i register TIME_TICK event broadcast receiver for android app even if app is running or not

i want to fire some event when system time matches the time stored in my database.I tried out this by using TIME_TICK broadcast receiver.when this receiver receive broadcast, i match my database entries with system time...but problem is that i can register this broadcast receiver from activity only...can't register from manifest file.so, when i close my app or remove it from recent apps list, this broadcast receiver stops working. 我想在系统时间与数据库中存储的时间匹配时触发一些事件。我使用TIME_TICK广播接收器尝试了此操作。当此接收器接收广播时,我将数据库条目与系统时间进行了匹配...但是问题是我可以仅从活动中注册此广播接收器...无法从清单文件中注册。因此,当我关闭我的应用程序或将其从最近的应用程序列表中删除时,此广播接收器将停止工作。 I refer the documentation that says that "TIME_TICK can only register from activity , not from manifest file". 我引用的文档说“ TIME_TICK只能从活动而不是清单文件中注册”。 I also tried to find solution for my problem on stackoverflow and on google but i can't found proper answer. 我也试图为我在stackoverflow和google上的问题找到解决方案,但找不到正确的答案。 so, if you know how to solve it then reply my question and thanks in advance. 因此,如果您知道如何解决,请提前回答我的问题并表示感谢。

i want to fire some event when system time matches the time stored in my database 我想在系统时间与数据库中存储的时间匹配时触发一些事件

Use AlarmManager . 使用AlarmManager

how can i register TIME_TICK event broadcast receiver for android app even if app is running or not 我该如何为Android应用注册TIME_TICK事件广播接收器,即使该应用是否正在运行

That is not possible, as it is incredibly inefficient. 这是不可能的,因为它效率极低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM