Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Akshay Shivpuri
2,917 Pointsactivity lifecycle in Android
When we launch a simple android app and click on the back button then the onPause() method gets invoked followed by onStop() and onDestroy() method. But when we click on the Home button when the app is active then only onPause() and onStop() method gets called. Why doesn't the onDestroy() method gets called then?
1 Answer
Andrew Pham
3,492 PointsI believe it is a design decision of Android. It allows users more control over the device. It's assumed that when you press home, you may just need to get to your home screen quickly and come back to the app later. Pressing the back button is a bit more direct and is assumed to mean you want to exit the application.
This feature works in favour of big games, during the middle of a game you may need to quickly text your friend or do some quick action with another app (requiring you to go back home), you can press home then resume the game alter without having to initialise the whole thing again.