如何使用Xamarin Essential确定网络类型是2g,3g还是4g

时间:2019-01-13 07:11:01

标签: c# xamarin xamarin.forms cross-platform

我如何使用Xamarin Essential来确定网络类型是2g,3g还是4g

我知道xamarin Essential具有识别连接类型的功能

var current = Connectivity.NetworkAccess;

if (current == NetworkAccess.Internet)
{
     // Connection to internet is available
}

但是如果是互联网类型的话,我想知道它是否是2g / 3g / 4g / 5g

1 个答案:

答案 0 :(得分:1)

检查连接插件 https://github.com/jamesmontemagno/ConnectivityPlugin 和ConnectionTypes

public enum ConnectionType
{
    /// <summary>
    /// Cellular connection, 3G, Edge, 4G, LTE
    /// </summary>
    Cellular,
    /// <summary>
    /// Wifi connection
    /// </summary>
    WiFi,
    /// <summary>
    /// Desktop or ethernet connection
    /// </summary>
    Desktop,
    /// <summary>
    /// Wimax (only android)
    /// </summary>
    Wimax,
    /// <summary>
    /// Other type of connection
    /// </summary>
    Other,
    /// <summary>
    /// Bluetooth connection
    /// </summary>
    Bluetooth
}