如何确定,如果互联网连接是目前可用的和积极的在Android设备上? [英] how to determine, if an internet connection is currently available and active on an android device?

查看:142
本文介绍了如何确定,如果互联网连接是目前可用的和积极的在Android设备上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的Andr​​oid应用程序,需要通过互联网从远程服务器加载数据。此更新-functionaliy显然需要设备不仅可连接到某些类型的网络,但也到互联网。

i have this android application that requires to load data from a remote server via the internet. this update-functionaliy obviously requires the device to not only be connected to some kind of network, but also to the internet.

这样:就是要安排更新服务在一定日期和启动时,它应该确定它是否真正能达到目标服务器上。因此,一个简单的连接到无线网络的设备?不足够了,作为装置可被连接到不提供网络连接的无线网络。像一个PING需要...

so: is want to schedule the update-service to some date and when it starts, it should determine whether it actually CAN reach the target server or not. therefore, a simple "is the device connected to wifi?" does not suffice, as the device may be connected to a wireless network that does not offer internet access. something like a PING is required...

什么最简单的/最好的方法来确定,如果有一个互联网连接,请即服务器可以访问?

whats the easiest / best way to determine, if there is an internet connection is available i.e. server is reachable?

推荐答案

看看这的回答这里计算器。它应该是你正在寻找的地方。

Take a look at this answer here on StackOverflow. It should be just what you are looking for.

这篇关于如何确定,如果互联网连接是目前可用的和积极的在Android设备上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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