How to resume an app (Windows Store apps using JavaScript and HTML)

4 out of 6 rated this helpful - Rate this topic

Learn how to refresh content when the system resumes your Windows Store app.

The system suspends your app whenever the user switches to another app or to the desktop. The system resumes your app whenever the user switches back to it. When the system resumes your app, the content of your variables and data structures is the same as it was before the system suspended the app. The system restores your app exactly where it left off, so that it appears to the user as if it's been running in the background. However, your app may have been suspended for a significant amount of time, so it should refresh any displayed content that might have changed while it was suspended, such as news feeds or the user's location.

The following steps will show you how to register for the resuming event and use it to refresh stale content after a suspend.

Instructions

Step 1: Register for the resuming event

Register for the resuming event, which indicates that the app has resumed after being suspended.


Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);

Step 2: Refresh displayed content after suspension

When your app receives the resuming event, it has the opportunity to refresh any content that may have become stale while the app was suspended.


function resumingHandler() {
    // TODO: Refresh network data
}

Remarks

If your app doesn't have any content that could become stale and may need refreshing, there's no need for it to handle the resuming event.

A note about debugging using Visual Studio:   When your app is attached to the Visual Studio debugger, you can send it a resume event. Make sure the Debug Location toolbar is being shown, and click the drop-down next to the Suspend icon. Then choose Resume.

Complete example

See the App activate and suspend using WinJS sample and the App activate, resume, and suspend using the WinRT sample for complete code examples showing how to handle app lifecycle events.

Related topics

Tasks
How to activate an app
How to suspend an app
Conceptual
Application lifecycle
Guidelines
Guidelines for app suspend and resume
Reference
Windows.UI.WebUI.WebUIApplication.resuming

 

 

Build date: 10/26/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.