Over the last week or so, fellow Microsoft MVP, Rob Farley has been getting familiar with my HTC Touch device. One of his biggest pain points is that applications frequently get closed when they are not in use to free up memory for other applications. Unfortunately this seems to be a little known fact about Windows Mobile – that when it is memory constrained it will go through the background applications requesting that they close.
There are two sides to correctly handling this scenario from a development point of view. Firstly, at an application level you do get an opportunity to refuse closure. For example if the application is in the middle of downloading updates or refreshing content then it can hold off closing until it has completed. Bearing in mind that this will of course slow down the running of other applications and may prevent new applications loading during this time.
The second point to note is that from an end user perspective they shouldn’t care if an application is running or not. When they click on the application icon it should always go to where they were in the application the last time they used it, regardless of whether the application has had to open or just show itself. In fact this is one of the reasons that currently Windows Mobile doesn’t have a built in Task Manager (other than the Running Programs item under Settings->System as such.
An example of applications that don’t restart well, and is really annoying because it always shutdown when placed into the background, is Google Maps. This application insists on showing you their disclaimer splash screen every time you run the application – in this case it is particularly bad because while the application is active it prevents the backlight from dimming or the device going into standby (which of course drains battery life very quickly).