如何使用MonoTouch检查互联网访问?我不在乎互联网是来自WIFI还是蜂窝网络,我只关心是否有互联网接入。使用Monoouch检查互联网访问
14
A
回答
20
使用米格尔的可达性类(在这里找到:https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs)你可以这样调用:
if(!Reachability.IsHostReachable("http://google.com")) {
// Put alternative content/message here
}
else
{
// Put Internet Required Code here
}
希望这有助于
ChrisNTR
以上链接Reachabiity类已转移到以下内容:https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs – 2011-09-13 06:21:09