I'm working on Windows Phone 7 application using a background-agent to update a Live Tile. The problem I've ran into has to do with disabling and re-enabling the background-agent. Users has the ability to disable background-agents for a specific application under settings (Settings - Applications - Background Tasks).
If the Background Agent is disabled, I get the expected behavior of an InvalidOperationException with the message "BNS Error: The action is disabled" if I try to schedule the agent using the following code:
ScheduledActionService.LaunchForTest(PeriodicTaskName, TimeSpan.FromSeconds(20));
If the user goes back into the settings menu and tick the check box "Turn background tasks back on for this app the next time I open it" I still get the same exception.
So my question is how do I execute a task that has been re-enabled?
The MSDN documentation describes the behavior of disabled tasks, but now how to enable them again.