【问题标题】:Xamarin Essentials - Connectivity.NetworkAccess incorrect on Pixel 3?Xamarin Essentials - Pixel 3 上的 Connectivity.NetworkAccess 不正确?
【发布时间】:2019-05-30 14:24:12
【问题描述】:

我有一个类似这样的功能:

private bool IsConnected()
{
    if (DeviceInfo.DeviceType == DeviceType.Unknown)
        return false;

    var current = Connectivity.NetworkAccess;

    if (current == NetworkAccess.Internet)
        return true;

    return false;
}

我的队友报告此功能的问题为零,并且正在使用各种设备。我的个人设备是使用 Google Fi 和 Google VPN 的 Google Pixel 3。当我将其切入飞行模式时,我看到 Connectivity.NetworkAccess 设置为 NetworkAccess.None。但是,当我关闭飞行模式并明确关闭移动数据和 Wifi 时,我看到 Connectivity.NetworkAccess 设置为 NetworkAccess.Internet

与此相关,Connectivity.ConnectionProfiles 报告了一个个人资料:ConnectionProfile.Unknown

这是预期的行为吗?我是否应该同时检查Connectivity.ConnectionProfilesConnectivity.NetworkAccess 以确定设备是否真正连接到网络?

【问题讨论】:

  • 可能值得在比抽象更低的级别进行调试。查看Android APIs being used 以进一步了解并可能在本地运行其中一些以确保它不会遇到无效的代码路径。

标签: android xamarin xamarin.essentials


【解决方案1】:

如果您无法访问互联网并且 Connectivity.NetworkAccess 是 NetworkAccess.Internet,那么这不是预期的行为。

您可以在他们的 github 上提交问题:https://github.com/xamarin/Essentials/issues

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 2020-12-15
    • 1970-01-01
    相关资源
    最近更新 更多