简体   繁体   English

Android C2DM:如果设备关闭,最好的处理方法是什么

[英]Android C2DM: What is the best way to handle if the device if off

I'm using C2DM in a project. 我在一个项目中使用C2DM。 I want to show device status (battery remaining, sdcard availability...) when user logs in my website. 当用户登录我的网站时,我想显示设备状态(电池剩余电量,sd卡可用性...)。 Here is my implementation: 这是我的实现:

  • Upon their log in, the 3rd-application server (my website) will send a "login" push notification message to the device 登录后,第3个应用程序服务器(我的网站)将向设备发送“登录”推送通知消息
  • When the device receives the "login" notification, it will send the latest device status to the 3rd-application server 设备收到“登录”通知后,会将最新的设备状态发送到第三应用程序服务器

If when the device is offline, the 3rd-application server will not receive any update. 如果设备离线,则第3应用程序服务器将不会收到任何更新。 I currently define a "timeout" (1 minute) to detect if the device is offline or is not able to send device status. 我目前定义了一个“超时”(1分钟)来检测设备是否离线或无法发送设备状态。

My questions are: 我的问题是:

  • Is there a better way to implement this app? 有没有更好的方法来实现此应用程序?
  • How to choose a best "timeout" value? 如何选择最佳的“超时”值?

"The best timeout value" is the one that suites your application or your needs the best. “最佳超时值”是适合您的应用程序或您的需求最佳的值。 If you think trying every other minute might catch the device in an online state, then that's the way to go. 如果您认为每隔一分钟尝试一次可能会使设备处于联机状态,那么这就是方法。

I personally would refresh at a larger interval (10 minutes for example, or 30), or on pressing a "Try again" button. 我个人会以较大的间隔(例如10分钟或30分钟)或按“重试”按钮来刷新。

I think "a better way" would be to store every time the last received data from every device. 我认为“更好的方法”是每次存储来自每个设备的最新数据。 So, if I log in and my device is offline, my last retrieval of the status will be displayed, alongside with its date(eg Battery: 59%, Yesterday at 3:44 PM). 因此,如果我登录并且我的设备处于离线状态,则将显示我最近一次获取的状态及其日期(例如,电池:59%,昨天下午3:44)。

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

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