android - 如何从 Android 以有限的时间间隔轮询 Web 服务?

标签 android web-services notifications android-notifications android-alarms

我正在开发一个 android 应用程序来显示通知。我如何以有限的时间间隔(比如 10 分钟间隔)轮询 web 服务以检查是否有任何更新并在 android 通知面板中显示为通知。

最佳答案

不需要服务。我感觉像是破纪录了。在这个用例中,服务将在 95% 的时间里什么也不做,但仍在使用系统资源,更重要的是耗尽电池。

请参阅我对使用 AlarmManager 中的警报的类似问题的回答:

Running task periodicaly(once a day/once a week)

编辑:

有关如何实现通知的信息,请参阅 Android 开发网站上的教程:http://developer.android.com/guide/topics/ui/notifiers/notifications.html

关于android - 如何从 Android 以有限的时间间隔轮询 Web 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9226927/

相关文章:

android - 使用 Firebase 云消息传递显示大 View 通知

android - react native 错误:重复的资源, Assets 出现在某些屏幕中,而不出现在其他人的android版本APK中

android - 如何本地化Google Play和App Store应用程序链接?

web-services - SSIS Web服务任务无法连接到远程服务器

azure - 经过身份验证的推送通知,无需将应用程序发布到 Windows Phone 应用商店

c++ - 为什么在 IUserNotificationCallback COM 对象上查询 IMarshall 接口(interface)?

Android WebView 触摸事件链接

android - 11.0.4 以上版本的 Google Play 服务下载

web-services - Web 框架在读取正文之前是否检查授权 header ?

java - 如何为给定 xml 的客户端 saaj 创建 SOAP 请求