Home » Android » Difference between android Home key and Back key and their behaviour

Difference between android Home key and Back key and their behaviour

Posted by: admin June 15, 2020 Leave a comment

Questions:

Can anyone point me out or explain what is the difference between android Home key and Back key and their respective behavior related to an android app/activity.

Thank you.

How to&Answers:

In addition to @Fosco’s comments, using back will usually cause an app to exit, where home will leave it running. This is dependent on the application, but the general pattern is to exit the app when using back on the last activity.

Answer:

Back Key :

  1. If you press Back Key, onPause(), onStop() and onDestroy() callbacks will called.

  2. Activity will created again by system calls onCreate() callback, then onStart() and onResume() callbacks will be followed.

Home Key :

  1. If you press Home Key, onPause() and onStop() callbacks will called.

  2. Here Activity will restart by system calls onRestart() callback, then onStart() and onResume() callbacks will be followed.

Answer:

Back key destroys the current Activity, home key doesn’t. In the Activity lyfecycle, pressing back calls all the way to current activity’s onDestroy() method. On the other hand, pressing home pauses the Activity, which stays alive in background.

Answer:

The home key takes you to the home screen, the back key takes you back to the previous activity (or home if there’s no activity to go back to.)

If you are at the home screen and launch Messaging, then hit back, it’s the same as hitting the home key.

If you’re in Email and get an alert for a text message, and you choose the notification which takes you to Messaging, then hit Back, you’ll go back to Email.

edit: as mentioned by Tim Coker, when the back button takes you to the home screen, it usually terminates the activity. I think this is based on the app, whether it terminates or stays resident.