2016-11-09 1 views

Antwort

1

Seine ganz einfach

1.Declare dies in Ihrer Seite

private WiFiAdapter firstAdapter; 
private string savedProfileName = null; 

2.Populate es

var result = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(WiFiAdapter.GetDeviceSelector()); 
      if (result.Count >= 1) 
      { 
       firstAdapter = await WiFiAdapter.FromIdAsync(result[0].Id); 
      } 

3.Add diese Fähigkeit zu Ihrer App-Manifest-Datei

<DeviceCapability Name="wiFiControl" /> 

4.Überprüfen Sie zu w hich Netzwerk wlan verbunden

if (firstAdapter.NetworkAdapter.GetConnectedProfileAsync() != null) 
      { 
       var connectedProfile = await firstAdapter.NetworkAdapter.GetConnectedProfileAsync(); 
       if (connectedProfile != null && !connectedProfile.ProfileName.Equals(savedProfileName)) 
       { 
        savedProfileName = connectedProfile.ProfileName; 
} 

5.Here savedProfileName haben SSIDs seine connected.Also connectedProfile.IsWlanConnectionProfile wahr ist, wenn verbunden über Wi-Fi und connectedProfile.IsWwanConnectionProfile wird wahr sein, wenn verbunden über das Mobilfunk Danach Sie können auf diese Weise nach Internet suchen:

public static bool IsInternet() 
{ 
    ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile(); 
    bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess; 
    return internet; 
} 

Ich hoffe, es hat geholfen.

+0

Vielen Dank Kumpel, es hat für mich funktioniert. – Uwpbeginner

Verwandte Themen