当网络访问下降时,如何停止运行进度对话框?
我有一个应用程序可以访问网站来获取 XML 进行处理。这个过程是在一个单独的线程中,当我有 3G 或 WiFi 可用时,它可以正常工作。我还有在实际运行线程之前检查信号的代码,因此它不会在无连接的情况下尝试。
在测试过程中,我走进一栋屏蔽了所有信号的建筑物,因此当我在外面并且有信号时进程就开始了,但是当我进入内部时信号下降并且我的进度对话框继续运行,我不得不手动关闭程序以使其恢复。
如果发生这种情况,是否有一个好的方法来处理这个问题,而不需要用户手动关闭应用程序?
I have an app that goes out to a website to grab XML for processing. This process is in a separate thread and works fine when I have 3G or WiFi available. I also have code that checks signal before actually running the thread so it won't attempt with no connectivity.
During my testing, I walked into a building that blocked all signal so the process started while I was outside and had signal but when I went inside the signal dropped and my Progress dialog just kept running, I had to manually shut the program down to get it to recover.
Is there a good way to deal with this without requiring the user to manually shut down the app if this situation happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
向您的 HttpClient 提供超时参数并捕获 SocketTimeOutException
Supply timeout parameters to your
HttpClient
and catch SocketTimeOutException