Leaving an Android application
One of the strange things with android is that there is no "the user has closed the application" event. Applications activities often just go to the background, and the android system may kill them whenever it wants, even when another activity of the application is still running in the foreground. |
![]() |
You can not be sure that activities you started and sent to the background are sill there storing their state, and if you are just an android user, you can not be sure that applications that you left simply by pressing back button are completely destroyed.
To make it more complex, using intents it is even possible to start an activity of another application.
You must clearly understand this when you are developing android, otherwise you can make some typical mistakes, and still the application will seem like working... until there is sufficient memory, or a phone call does not interrupt your application.
Usually each activity should open/initialize the resources it needs, even if it is opened from an activity where the same resources were previously acquired, because on low memory the system may kill that activity and free its resources.
(On a level below the activities of course you can track the resource accesses from the activities to do not open and close resources multiple times between activities, but the activity itself must suppose that it needs to be opened at start)
For example a typical error I have seen, when the first activity, which is only a splashScreen with a logo was responsible to open the database in onCreate, and close it in onDestroy, and all other activities were using the database instance of that activity.

This kind of problems often do not come out when you use the application continuously, but if you send it to the background (for example simply pressing home), then run some other application, and after this when you come back to your application, you may find some of its activities killed by the system.
Check out Activity Lifecycle carefully when starting to work with Android, because it can be a bit weird at first.
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@Idevicegazette (iDevice Gazette)
GSM-to-Skype bridge lets you lose those roaming fees http://bit.ly/lbRJeh #android
11 years 45 weeks ago -
@tommy_banane (tom b.)
RT @AndroidFavorite: #Android New Desktop Android Market Is Live, Adds Several New Features http://zorr0.nl/lFwXNz
11 years 45 weeks ago -
@dwilliams5 (Dennis Williams)
just completed a runtastic run of 3.02 km in 40 min 11 s with #runtastic #Android App: http://tinyurl.com/5tvrpe3
11 years 45 weeks ago -
@S_Pinz (Spinz!)
RT @Androidheadline: Out of box #LG Optimus 3D got Quadrant 2420 score. Thanks @blink_c #io2011 #android http://twitpic.com/4whkdz
11 years 45 weeks ago -
@tayaitapps (Taya IT)
Next Google TV Looks A Lot Like Android http://t.co/dvlTim3 via @alleyinsider #google #apple #android #tv #honeycomb
11 years 45 weeks ago
Poll
Useful resources
Android Development Projects
- iOS/Android Developer to take older Games and bring them Current
- Android apps developer - need to finish urgent.
- Buliding MobileApp For onlie order
- looking for android APP developers
- Create an ecommerce app
- text-to voice for smartphones IOS - GOOGLE - HARMONY - AND ALEXA
- Optimize Images on App
- Create small feature with drag-drop text for Android
- Scouting for advanced website and Mobile apps developers. Potential Long-term contract.
- BLACK SCREEN