android 服务需要处理连接失败 - 如何处理?
我有一个应用程序可以定期从互联网检索数据(每周 3 次)。
服务器上的数据可通过 XML api(我构建的)获取,并且运行没有任何问题。
然而,某些用户的手机在拨打电话时并未开机/连接。
处理这种缺乏网络连接故障的最佳方法是什么?
实现网络连接监听器?这是一个坏主意吗?
我始终可以在手机启动时运行该服务,但不能保证它们此时会建立连接并运行。
有点困惑。任何帮助表示赞赏。
I've got an app that retrieves data on a regular basis from the internet (3 times a week).
The data on the server is available via an XML api (which I built) and which works without any problem.
However, some of the users handsets are not on/connected when the call is made.
What is the best way to handle this lack of net connection failure?
Implement a net connection listener? Is this a bad idea?
I can always run the service at phone startup, but there are no guarantees that they will have a connection up and running at that point.
Slightly confused. Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我真诚地希望您通过
AlarmManager
实现这一点,并且您每周 3 次的实现是一个重复的警报。在这种情况下,请从现在起 X 分钟安排一次一次性闹钟,然后重试。I sincerely hope you are implementing this via
AlarmManager
, and your three-times-a-week implementation is a repeating alarm. In that case, schedule a one-off alarm for X minutes from now, and try again.