Delay Closing Mobile Apps on Exit

When a user switches to another application on a mobile device AIR on mobile applications keep running. It continues to hold on to resources, fire off events, and has the potential to use power draining resources like network calls, or geolocation if your app makes use of them.
That’s why one of the first tips you see is to kill or tombstone your application when the user switches away from it. In general, unless you have a good reason to do not do this, you should. Your users might not notice that you drain their battery to zero, but then again they might.
But I have a good reason for not wanting to do this right away. Actually I have a few:

  • As a user, I frequently accidentally hit the home instead of back button
  • As a user, I frequently lookup stuff on the web then come back to an application.
  • As a developer, I frequently makes calls to OS resources like the camera or mapping in my app.

All these add up to needing to revisit closing on exit.
I’d like to get the benefit of closing on exit in terms of resource usage, but I’d like a grace period. So, my solution, fire off an event when a user leaves the application, that sets a timer to shut down the app. Then if the user returns, kill that timer.
Simple, easy, and best of both worlds.

https://gist.github.com/1051820.js

4 thoughts on “Delay Closing Mobile Apps on Exit

  1. I don’t think apps should kill themselves when the user switches away because it is the mobile OS’ job is to do this intelligently. If you buy into that notion, then your use case here is eliminated because the OS will not kill the app for a while. What a programmer should do however is minimize resource use where possible when the app goes “to the background” by turning off geolocation etc.

    Like

  2. @Randy, that’s fair. I get your point and tombstoning is the answer for you. Which you can totally do. The general recommendation from Adobe and others in the community is “close on exit.” I’m pointing out a slightly softened version of that position.

    Like

  3. Nice. I pause my game on deactivated and let the user resume on return. On a side note: I hate applications that exit on pressing the back button, I think it’s bad user experience.

    Like

Leave a Reply to tpryan Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s