WP7 Development Tip of the Day: Understanding Deactivating

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

Tags:

WP7 Tip of the Day | Windows Phone

Comments

9/29/2010 10:21:55 PM #

JR

... While launching and (de ?)activating describe the two ways that your app can become the foreground (running) app ...

JR Taiwan

9/30/2010 1:35:32 PM #

brad

Thanks JR!

brad United States

9/30/2010 1:38:24 PM #

trackback

WP7 Development Tip of the Day: Understanding Closing

WP7 Development Tip of the Day: Understanding Closing

code badger

Comments are closed

About Brad

Brad Tutterow lives in Illinois and works in Missouri. He has 12 years of experience developing web sites and Windows applications using a variety of technologies and is most excited currently about Silverlight, Windows Phone 7, Halo Reach, and Visual Studio 2010.