检查'Restrict background data'在 Windows Phone 上是否处于活动状态


Data sense 中有"限制后台数据"

和"在漫游时限制后台数据"中的设置。它们阻止后台任务,而不向应用程序发出任何通知。如何从应用程序检查他们的状态,以便我可以提醒用户?

我认为异常消息是检测它的唯一方法。就像在后台任务示例代码中一样。

    // Place the call to Add in a try block in case the user has disabled agents.
    try
    {
        ScheduledActionService.Add( task );
    }
    catch ( InvalidOperationException exception )
    {
        if ( exception.Message.Contains( "BNS Error: The action is disabled" ) )
        {
           // Background agents for this application have been disabled by the user.
        }
        if ( exception.Message.Contains( "BNS Error: The maximum number of ScheduledActions of this type have already been added." ) )
        {
        }
        //...
    }

相关内容

最新更新