![](/img/trans.png)
[英]How I can find out the available free space in a universal Windows Phone 8.1 App
[英]How can I determine whether I am connected to WiFi or a mobile network in Windows Phone 8.1 (Universal app)?
我正在使用Windows Universal應用程序(Windows 8.1和Windows Phone 8.1之間的共享后端,而不是Silverlight)。 該應用程序通過Azure移動服務連接到Azure。 在應用程序的設置中,我希望只有通過WiFi網絡才能進行同步選項。
如何確定手機是連接到WiFi還是移動網絡? 雖然從我的研究中我已經找到了使用舊版Windows Phone和Silverlight的方法,但似乎我只能確定該設備是否在Windows Universal應用程序中連接到互聯網。
我相信你可以使用類似於以下內容的東西從ConnectionProfile
確定這些信息:
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;
}
還有IsWwanConnectionProfile
屬性,用於確定連接是否通過“移動”連接(3g等)。
我認為這是檢查互聯網可用性的唯一方法:
bool IsConnected = NetworkInterface.GetIsNetworkAvailable();
if (IsConnected)
{
// Do Something
}
else
{
// Do something different
}
這個鏈接是我的參考。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.