public int getStatisticsNetType() { NetworkInterfaceList interfaceList = new NetworkInterfaceList(); NetworkInterfaceInfo interfaceInfo = interfaceList.First(); switch (interfaceInfo.InterfaceSubtype) { case NetworkInterfaceSubType.Cellular_3G: case NetworkInterfaceSubType.Cellular_EVDO: case NetworkInterfaceSubType.Cellular_EVDV: case NetworkInterfaceSubType.Cellular_HSPA: return(NETTYPE_3G); case NetworkInterfaceSubType.Cellular_GPRS: case NetworkInterfaceSubType.Cellular_EDGE: case NetworkInterfaceSubType.Cellular_1XRTT: return(NETTYPE_2G); case NetworkInterfaceSubType.Cellular_EHRPD: case NetworkInterfaceSubType.Cellular_LTE: return(NETTYPE_4G); case NetworkInterfaceSubType.WiFi: return(NETTYPE_WIFI); default: return(NETTYPE_NON); } }
/// <summary> /// 是否连接网络 /// </summary> /// <returns></returns> public static bool IsOnline() { var interfaceList = new NetworkInterfaceList(); var interfaceInfo = interfaceList.First(); bool connected = interfaceInfo.InterfaceState == ConnectState.Connected; return connected; }
public CurWifiInfo getCurWifiInfo() { CurWifiInfo info = new CurWifiInfo(); NetworkInterfaceList interfaceList = new NetworkInterfaceList(); NetworkInterfaceInfo interfaceInfo = interfaceList.First(); if (!DeviceNetworkInformation.IsWiFiEnabled) { return(null); } info.ssid = interfaceInfo.InterfaceName; return(info); }
public bool isNetworkConnected() { NetworkInterfaceList interfaceList = new NetworkInterfaceList(); NetworkInterfaceInfo interfaceInfo = interfaceList.First(); if (interfaceInfo.InterfaceState == ConnectState.Connected) { return(true); } else if (interfaceInfo.InterfaceState == ConnectState.Disconnected) { return(false); } else { return(false); } }
public int getNetInfo() { NetworkInterfaceList interfaceList = new NetworkInterfaceList(); NetworkInterfaceInfo interfaceInfo = interfaceList.First(); Debug.WriteLine("NetInfo:" + interfaceInfo.InterfaceType); switch (interfaceInfo.InterfaceType) { case NetworkInterfaceType.None: return(ENoNet); case NetworkInterfaceType.Wireless80211: return(EWifi); case NetworkInterfaceType.MobileBroadbandCdma: case NetworkInterfaceType.MobileBroadbandGsm: return(EMobile); default: return(EOther); } }