使用monotouch检查互联网接入 [英] Check for internet access with monotouch

查看:114
本文介绍了使用monotouch检查互联网接入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用MonoTouch检查互联网访问?我不在乎互联网是来自WIFI还是Cell Network,我只关心是否有互联网接入。

How can I check internet access with MonoTouch? I don't care if the internet comes from a WIFI or the Cell Network, all I care is whether there is internet access or not.

推荐答案

使用Miguel的Reachability类(可在此处找到: https:/ /github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs )你可以这样称呼:

Using Miguel's Reachability class (found here: https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs) you can just call it like this:

if(!Reachability.IsHostReachable("http://google.com")) {
    // Put alternative content/message here
}
else
{
    // Put Internet Required Code here
}

希望这个帮助,

ChrisNTR

这篇关于使用monotouch检查互联网接入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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