Launching, resuming, and multitasking (XAML)
Learn how to launch, suspend, and resume your app. Also learn about file associations, AutoPlay, transferring data in the background, and running your own code in the background with background tasks.
Roadmap: How does this topic relate to others? See:
When users move your app off-screen, Windows 8 suspends your app in memory. This allows another app to have the foreground. When an app is suspended, it is resident in memory, and Windows has stopped it from running.
When users bring your app back to the foreground, they expect the app to resume where they left off. As long as your app stays suspended, Windows automatically preserves your app's data in memory and restores it when your app resumes. Apps are also terminated occasionally, so your app should use suspending events to save its current state.
Note If you need to do asynchronous work when your app is being suspended you will need to defer completion of suspend until after your work completes. You can use the GetDeferral method on the SuspendingOperation object (available via the event args) to delay completion of suspend until after you call the Complete method on the returned SuspendingDeferral object.
You can launch the user's default app for a file type or URI. You can also enable your app to be the default app for a file type or URI scheme name.
When users connect a device to their computer, you can ensure your app is available for them to choose.
Windows helps your app manage file transfers to and from locations on the web, even if the user switches to a different app.
You can use background tasks to run lightweight code in the background. Any app can register a background task in response to certain system events. Background tasks can't run code that directly updates the UI; instead, they show information to the user with tile updates, badge updates, and toast notifications. Some apps, like mail, VOIP, and IM, allow the user to communicate in real-time. If the user allows, your app can show a badge or tile on the lock screen. When your app is on the lock screen, it gains access to real-time background tasks.
For detailed guidance on background tasks see Supporting your app with background tasks.
You can also keep providing functionality from the background with notifications and background audio. See the following topics outside of this section.
Use tiles, badges, and toast notifications to show updates when the app isn't running.
Use WNS push notifications to send toast, tile, and badge updates from a cloud service.
Your app can keep running in the background if it's playing continuous audio, such as music or an audio book. See How to play audio in the background.
Kid’s Corner is a Windows Phone feature that allows the user to put their phone in a special mode for kids, in which only the apps and media they specify can be accessed. An app can detect at run time if it is running in Kid’s Corner mode and modify its behavior and UI to be appropriate for a child user. See Detecting when your app is running in Kid's Corner mode.