使用单点触控检查互联网访问 [英] Check for internet access with monotouch

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

问题描述

如何使用 MonoTouch 检查互联网访问情况?我不在乎互联网是来自 WIFI 还是蜂窝网络,我只关心是否有互联网接入.

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
}

希望这会有所帮助,

克里斯NTR

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

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