by brad
29. September 2010 14:36
In the previous tip, I wrote about launching and activating. Today’s tip covers deactivating and tomorrow’s tip will cover closing. While launching and activating describe the two ways that your app can become the foreground (running) app, deactivating and closing describe the two ways that your app can stop being the foreground app.
Deactivating is the way that Windows Phone tells your application that it is being replaced as the foreground application but that this may only be temporary. This can happen if the user hits the Start button, launches a launcher or chooser from your application, or the phone locks because of inactivity.
Since deactivated applications can become the foreground application again, and because this activity should be transparent to the user, the key to understanding deactivating from a developer perspective is to understand that this is where you need to persist your transient state and persistent data. When the application is reactivated and is the running application once again, this data is used to restore your app to the same state it was in when the user last left it. See the tip on launching and activating.
Some tips for dealing with deactivation
- If the user is in a odd mood and presses Start + Back real quick, your application will be deactivated without being reactivated. Crazy, huh? So don’t do anything in your Deactivated event that will stop the app from working.
- There is no guarantee that the user will ever come back to your application once it is deactivated, so persistent data should also be stored.
- Your app has 10 seconds to do whatever it needs to do when it is deactivated.
Other Resources
More Tips