WinRT 中检查 WiFi 是否可用

 1 public static bool IsWifiConnected()
 2 {
 3     bool isWifiConnected = false;
 4     ConnectionProfile currentConnectionForInternet = NetworkInformation.GetInternetConnectionProfile();
 5     if(currentConnectionForInternet == null)
 6     {
 7         return false;
 8     }
 9     if(currentConnectionForInternet.IsWlanConnectionProfile)
10     {
11         if(currentConnectionForInternet.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess)
12         {
13             return true;
14         }
15     }
16     return false;
17 }

Windows 8.1 和 Windows Phone 8.1 Runtime 检测 WiFi 是否可用使用以上方法。(感觉比WP8 silverlight 麻烦-_-)

posted @ 2014-12-02 17:36  h82258652  阅读(472)  评论(0编辑  收藏  举报