【问题标题】:How to detect airplane mode programmatically in windows phone 10如何在 Windows Phone 10 中以编程方式检测飞行模式
【发布时间】:2017-03-28 10:47:36
【问题描述】:

ITNOA

我想以编程方式检测 Windows Phone 10(通用 Windows 应用程序)中的飞行模式。有什么办法吗?

谢谢

【问题讨论】:

    标签: uwp windows-10-mobile


    【解决方案1】:

    您可以将 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);
    

    【讨论】:

      猜你喜欢
      • 2012-07-25
      • 1970-01-01
      • 2016-08-29
      • 2016-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-03
      • 2021-03-24
      相关资源
      最近更新 更多