使用Pull通知从后台的服务器获取更新-Android [英] Get updates from a server in the background using Pull notification - Android

查看:91
本文介绍了使用Pull通知从后台的服务器获取更新-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在android应用中实现一项功能,即使该应用在后台/未运行,该功能也会定期从服务器提取信息.

I want to implement a feature in an android app, which periodically pulls information from a server even when the app is in the background / not running.

它应该每天调用一次Web服务并至少检查3-4次更新,如果可用,请在通知栏中拉出并显示它们.当用户单击通知时,应打开应用程序屏幕.

It should invoke a web service and check for updates at least 3-4 times in a day, and if available pull and show them in the notification bar. When the user clicks on the notification it should open up the app screen.

使用拉通知技术可行吗?有什么限制吗?您能否分享一些教程来帮助我实现这一目标.

Is that feasible using pull notification technology? Are there any constraints? Can you share some tutorials that will help me implement this.

谢谢..

推荐答案

Sudo步骤希望这些可以帮助您继续前进.

Sudo steps hope these helps you to go ahead.

  1. 创建一个服务该服务将调用服务器并获取 更新(如果可用)并生成通知.
  2. 在首次启动应用程序时使用AlarmManger设置重复警报 每8小时一次,一天一次4次.
  3. 创建BroadCastReceiver,它将由警报管理器每8次调用一次 小时.
  4. 然后从BroadcastReceive的onReceive()方法启动Service for 数据同步.
  1. Create One Service This service will call server and gets the updated if available and generate the Notification.
  2. Set Repeat Alarm using AlarmManger When application launches first time every 8 hours that is 4 times in a day.
  3. Create BroadCastReceiver which will called by alarm manager every 8 hours.
  4. And From BroadcastReceive's onReceive() method start the Service for data sync.

我假装您知道AlarmMAnager,Service和BroadcastReceiver.

I pretend that you know AlarmMAnager,Service and BroadcastReceiver.

正在使用的教程为此处

谢谢

这篇关于使用Pull通知从后台的服务器获取更新-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆