[英]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: 这是我的实现:
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: 我的问题是:
"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.