天天看點

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 麻煩-_-)

繼續閱讀