【发布时间】:2017-03-28 10:47:36
【问题描述】:
ITNOA
我想以编程方式检测 Windows Phone 10(通用 Windows 应用程序)中的飞行模式。有什么办法吗?
谢谢
【问题讨论】:
标签: uwp windows-10-mobile
ITNOA
我想以编程方式检测 Windows Phone 10(通用 Windows 应用程序)中的飞行模式。有什么办法吗?
谢谢
【问题讨论】:
标签: uwp windows-10-mobile
您可以将 this 文档和 MobileBroadbandRadioState 枚举用于 UWP 应用,但它是为移动运营商保留的,您不能在要上传到应用商店的应用中使用它。
首先,您必须编辑 Package.appxmanifest 文件并添加 rescap 命名空间
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp wincap rescap">
并添加新功能
<rescap:Capability Name="cellularDeviceIdentity"/>
在您的项目中添加此代码以检查飞行模式状态
var ids = MobileBroadbandAccount.AvailableNetworkAccountIds;
var account = MobileBroadbandAccount.CreateFromNetworkAccountId(ids[0]);
Debug.WriteLine(account.CurrentDeviceInformation.CurrentRadioState);
【讨论】: