Detecting the Previous Execution State

When a Windows Store app is activated, you can use the previousExecutionState property to determine whether the app is being newly launched, whether it was previously closed by the user, or whether it is coming back after being suspended and terminated.

Depending on the value of previousExecutionState, you might want to load default values or load the previous app state. For example, if you are creating a news app, then you probably want to load the previous article that the user was reading. If, on the other hand, the user has never run the app, then you might want to load a default page such as the home page.

Here’s what the code looks like for checking the previous state:

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.