检查Internet连接在机器人 [英] Check the Internet Connectivity in Android

查看:122
本文介绍了检查Internet连接在机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拉以及一些数据推并经由web服务的服务器。强制性的东西,我应该做的是连接性检查。我做了什么,现在是,我已经写了连通性检查code。在每一项活动就推前/拉动的结果从服务器设置。我知道它不是,我应该有code一个最好的办法。相反,这种连接检查应在运行一些事情一样的背景下,(在屏幕后面),并提醒用户,当WIFI / 3G变低/下降。

I am trying to pull as well as push some data to and from the server via webservice. The mandatory thing that should i have to do is connectivity check. What i have done right now is , i have written a connectivity check code in each activity before it pushes/ pulls the result set from the server. I know its not a best way that i should have to code. Instead this connectivity check should be running some thing like a background , (behind the screens) and alerts the user, when the WIFI / 3G becomes low / goes down.

什么是这样做的最佳方法是什么?

What is the best way to do so ?

请让我知道知道你的想法。

Please let me know know your thoughts.

感谢你。

推荐答案

您可以注册一个的BroadcastReceiver 来侦听连接变化。详细的岗位都可以在这里找到

You can register a BroadcastReceiver to listen for connectivity changes. A detailed post can be found here.

这篇关于检查Internet连接在机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆