本文介绍了如何确定我是否连接到WiFi或在Windows Phone的8.1(通用应用程序)移动网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我与(是Windows 8.1和Windows Phone 8.1,而不是Silverlight的共享后端)一个Windows应用程序的通用工作。该应用程序连接的Azure与移动服务到Azure。在该应用的设置,我想有同步只能通过WiFi网络出现的选项。 我怎么能确定手机连接到WiFi或移动网络?虽然从我的研究,我已经找到了与旧版本的Windows Phone和Silverlight来做到这一点,看来我只能确定设备是否连接到Windows通用应用互联网。 解决方案 我相信你能确定从的 ConnectionProfile 使用的东西类似: 使用Windows.Networking.Connectivity; VAR connectionProfile = NetworkInformation.GetInternetConnectionProfile(); // connectionProfile可以为空(例如飞行模式)如果(connectionProfile = NULL&放大器;!&安培; connectionProfile.IsWlanConnectionProfile){ //做点什么通过WiFi; } 也有 IsWwanConnectionProfile 属性,它用于确定是否连接是通过一个移动连接(3G等)。 I am working with a Windows Universal app (shared backend between Windows 8.1 and Windows Phone 8.1, not Silverlight). The app connects to Azure with Azure Mobile Services. In the settings for the app I would like to have an option for synchronisation to only occur over a WiFi network.How can I determine if the phone is connected to WiFi or a mobile network? Although from my research I have found ways to do this with older versions of Windows Phone and with Silverlight, it seems I can only determine if the device is connected to the internet in a Windows Universal app. 解决方案 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). 这篇关于如何确定我是否连接到WiFi或在Windows Phone的8.1(通用应用程序)移动网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-26 06:01