我了解Windows Phone 8.1应用程序生命周期:http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff817008%28v=vs.105%29.aspx
但是,是否可以在不使用应用程序时(停用后)保持应用程序的活动状态?
是否有可能实现以预定时间间隔向服务器发送一些数据的WP8.1应用程序?当它被取消激活时,是否可以在App中执行代码?
答案 0 :(得分:3)
您似乎需要PeriodicTask
Periodic agents run for a small amount of time on a regular recurring interval. Typical scenarios for this type of task include uploading the device’s location and performing small amounts of data synchronization.
答案 1 :(得分:2)
除了Silverlight apps, there are also Universal/Runtime apps之外,您已为WP8.1标记了自己的问题。值得一提的是,在Windows Phone 8.1运行时应用程序中,您有一点不同app lifecycle。
任何方式,当您的应用已暂停,已停用, Tombstoned 或进入未运行时国家,它正在停止。并且它无法在后台工作(使用官方API,除了Audioplayers,GPS跟踪应用程序和其他特别设计的模型)。 diffrenet案例也是在锁定屏幕下运行的应用程序(这是可能的,但它不是你要求的)。离开应用程序时,会引发Suspending event或WP Silverlight中的Deactivated - 请注意,这些事件的时间非常有限,无法保存应用程序的状态。
除了BackgroundAgents之外,还有一些方法可以在后台工作,从Windows Phone 8.1(Silverlight和Runtime)开始,您可以使用BackgroundTasks。可以按时间间隔和/或TimeTrigger触发它们(例如MaintanceTrigger,Registration),具体取决于special conditions {/ 3}}。
Here is a vary good article,您还可以找到一些信息at this article。