android 服务需要处理连接失败 - 如何处理?

发布于 2024-09-18 00:09:54 字数 241 浏览 5 评论 0原文

我有一个应用程序可以定期从互联网检索数据(每周 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悸初 2024-09-25 00:09:54

处理这种缺乏网络连接故障的最佳方法是什么?

我真诚地希望您通过 AlarmManager 实现这一点,并且您每周 3 次的实现是一个重复的警报。在这种情况下,请从现在起 X 分钟安排一次一次性闹钟,然后重试。

What is the best way to handle this lack of net connection failure?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文