Recently i was publishing an updated version of an application on the Marketplace for Windows Phone 7, and my update failed the testing process.
Comments: The user isuse presented with an error message when the location services are disabled on the device. The error
message that is displayed is not a user friendly message.
Steps to reproduce:
1. Turn on location service on device.
2. Launch the application and select a location
on the venues page.
3. Swipe to the map page and select view map.
4. When map is loaded press the Start button on the device. 5. Go to the settings of the device and turn off location service.
6. Press the Back button from the Start screen of the device to reactivate the application.
7. Notice a non-user friendly error notification appears.
In reality the problem is not related with the location services. Because i don’t use the location service (i only use the Bing Map for display only). In fact, the real problem it’s that i forgot to handle the Deactivated event and the Activated event.
Why do we have to handle the Activated and Deactivated event?
Windows Phone 7 doesn’t support multiple application running at the same time (except for some application approve by Microsoft). But when your application is running, for different reason (incoming phone call, the user click the start button, …) the application can be suspended. To eliminate some issues you should handle those event and make sure you persist important information.
One of the best place to handle these events is in the App.xaml. To do so you need to declare the events in the xaml code.
<!--Required object that handles lifetime events for the application-->
In the Activated event, you can store some data in the the Microsoft.Phone.Shell.PhoneApplicationService.Current.State dictionary. And in the Deactivated event, we can retrieve that information.
Make sure to test any scenario that a user may face. Currently, the testing process that Microsoft implemented is pretty exhaustive (which is good because it help ensure that the application in the Marketplace won’t crash).