开发者

How to use Miguel's Reachability classes?

开发者 https://www.devze.com 2023-02-12 21:58 出处:网络
I\'m currently using Miguel\'s Reachability class to figure out if my device can connect a certain server. However, there are situations when checking takes very long. My call is:

I'm currently using Miguel's Reachability class to figure out if my device can connect a certain server. However, there are situations when checking takes very long. My call is:

Reachability.IsHostReachable ( sUrl )

And I'm trying to reach my server's U开发者_开发技巧RL. But I'm not really interested in that. It would be enough to know if the device is currently registered in a WiFi network and if not, if it is connected through the carrier's GSM network. Wether it reach a host or not is secondary. As Reachability is not very well commented, I wonder if somebody knows what methods I would have to call?

EDIT: It would already be enough if somebody explained the meaning of InternetConnectionStatus() and LocalWifiConnectionStatus() to me. The funny thing is: the first one always returns true even if I turn WiFi off.


I tend to use

Reachability.RemoteHostStatus() == NetworkStatus.NotReachable

to check for a connection. The NetworkStatus enumeration also includes ReachableViaCarrierDataNetwork and ReachableViaWiFiNetwork which may come in handy for what you desire.

0

精彩评论

暂无评论...
验证码 换一张
取 消