当应用程序恢复在WP 8.1商店应用程序恢复事件不触发 [英] App Resuming event not firing when the app is resumed in WP 8.1 store app

查看:140
本文介绍了当应用程序恢复在WP 8.1商店应用程序恢复事件不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WP 8.1商店应用行为非常奇怪。应用程序恢复事件触发如预期时,我迅速浏览到别处,然后再回来。但是,如果我保持应用程序在后台一段时间,当回来的时候,应用程序触发构造和活动的OnNavigatedTo而不是恢复事件,并有黑色的恢复...屏幕几秒钟(约4秒) 。这是一个BackgroundAudio任务的应用程序。即使从MS样品BackgroundAudio应用程序的行为是这样的。任何人都知道什么是错在这里?

My WP 8.1 store app behaves very strangely. App Resuming event fires as expected when I quickly navigate away and then come back. But If I keep the app in background for some time and when comes back, the app fires the Constructor and OnNavigatedTo events instead of the Resuming event and has the black "Resuming..." screen for a couple of seconds(about 4 seconds).This is an app with a BackgroundAudio task. Even the sample BackgroundAudio app from MS behaves like this. Anyone knows what's wrong here?

推荐答案

我在建筑,使用背景音频任务以及一个WP 8.1的应用程序的过程。你解释一切都发生在我身上也。

I'm in the process of building a WP 8.1 app which uses a background audio task as well. Everything you explained happens to me also.

如果你看到恢复......几秒钟,那么它很可能意味着你的应用程序是被OS后终止第一个暂停。在这种情况下,恢复事件不会触发,因为你的应用程序被完全杀死,必须重新开始。当暂停(不是终止)的应用继续执行恢复,通常指。

If you see "Resuming..." for a few seconds, then it probably means your app was terminated by the OS after being suspended first. In this case, the Resuming event won't fire because your app was completely killed and must start again. "Resuming" usually means when a suspended (not terminated) app resumes execution.

当你的应用程序被终止,然后从应用程序切换器恢复,你的 Application.OnLaunched()方法重写将与 e.PreviousExecutionState == ApplicationExecutionState.Terminated 调用。在这种方法中,你应该检查一下以前的执行状态被终止,如果是这样,恢复应用到它以前暂停的状态。这给人的错觉是,应用程序从未被终止,他们可以恢复,他们当时在做什么用户。

When your app is terminated and then "resumed" from the app switcher, your Application.OnLaunched() method override will be invoked with e.PreviousExecutionState == ApplicationExecutionState.Terminated. In this method, you should check if the previous execution state was Terminated, and if so, restore the app to the state it was in prior to suspension. This gives the illusion to the user that the app was never terminated and they can resume what they were doing at the time.

如果您创建一个新的支点应用的Windows Phone 8.1项目(例如),您将看到应用程序生命周期事件被照顾的正确 App.xaml.cs

If you create a new Pivot App Windows Phone 8.1 project (for example), you'll see that the application lifecycle events are taken care of correctly in App.xaml.cs.

应用程序恢复事件触发如预期时,我快速地浏览了,才回来。

App Resuming event fires as expected when I quickly navigate away and then come back.

这是正确的行为。它需要几秒钟前一次它是由OS暂停应用已经后台运行,因此,如果您恢复应用程序的操作系统已经暂停之前,那么它会简单地从内存中恢复。

This is correct behavior. It takes a few seconds once the app has been backgrounded before it is suspended by the OS, so if you resume the app before the OS has suspended it, then it will simply resume from memory.

我不知道为什么背景音乐应用程序是终止更敏感。我甚至发现了Xbox音乐应用程序的行为类似。希望在Windows Phone的下一个版本,这个问题将得到解决。

I'm not sure why background audio apps are more susceptible to termination. I even find that the Xbox Music app behaves similarly. Hopefully in the next version of Windows Phone, this issue will be addressed.

仅供参考,这里的应用程序生命周期的图表从 MSDN (我建议你阅读此页有关应用程序生命周期的更多信息)

FYI here's a diagram of the application lifecycle from MSDN (I recommend you read this page for more information about the application lifecycle):

恢复只有从暂停到运行状态发生。

"Resuming" only occurs from the suspended to running states.

这篇关于当应用程序恢复在WP 8.1商店应用程序恢复事件不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆