简体   繁体   English

动态android状态栏通知

[英]Dynamic android status bar notification

I`ve an app that use sqlite for storage. 我有一个使用sqlite进行存储的应用程序。 In this database I have a table with multiple records that has datetime field. 在这个数据库中,我有一个表,其中包含具有datetime字段的多个记录。 I want to always push a status bar notification 12 hours before of each. 我想始终在每个状态前12小时推送状态栏通知。

I took a look at http://developer.android.com/guide/topics/ui/notifiers/notifications.html and understand how to use it, but don`t know how to run it periodically in background. 我看了一下http://developer.android.com/guide/topics/ui/notifiers/notifications.html并了解了如何使用它,但不知道如何在后台定期运行它。

Any tips? 有小费吗?

As the linked documentation mentions, you can create notifications from a local Service . 如链接文档所述,您可以从本地Service创建通知。 The first example actually describes how to use one for creating and managing notifications. 第一个示例实际上描述了如何使用它来创建和管理通知。

Additionally, the AlarmManager class might help you with an efficient implementation of said Service. 另外, AlarmManager类可以帮助您有效地实现所述服务。 I'd recommend to pay special attention to the notes regarding the phone's sleep cycle and wake locks. 建议您特别注意有关手机的睡眠周期和唤醒锁的注意事项。

Finally, you might want your Service to start on boot. 最后,您可能希望您的服务在启动时启动。 See this question for details . 有关详细信息,请参见此问题

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

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