How can I determine whether I am connected to WiFi or a mobile network in Windows Phone 8.1 (Universal app)?

為{幸葍}努か 提交于 2019-11-29 08:03:10

I believe you can determine this information from the ConnectionProfile using something akin to:

using Windows.Networking.Connectivity;

var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
// connectionProfile can be null (e.g. airplane mode)
if (connectionProfile != null && connectionProfile.IsWlanConnectionProfile) {
    // do something over WiFi;
}

There is also the IsWwanConnectionProfile property, which is used to determine if the connection is via a 'mobile' connection (3g, etc).

I think that this is the only way to check for internet availability :

bool IsConnected = NetworkInterface.GetIsNetworkAvailable();
        if (IsConnected)
        {
            // Do Something
        }
        else
        {
            // Do something different
        }

This Link is my reference.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!