Data Sense中的设置'限制背景数据'和'限制roamind时的背景数据'。他们阻止后台任务,而不通知应用程序。如何从应用程序检查他们的状态,以便我可以提醒用户?
答案 0 :(得分:0)
我认为异常消息是检测它的唯一方法。就像在background task sample code中一样。
// 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." ) )
{
}
//...
}