Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between android Home key and Back key and their behaviour

Tags:

android

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.

like image 682
user755499 Avatar asked May 17 '11 12:05

user755499


3 Answers

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.

like image 142
Silambarasan Poonguti Avatar answered Oct 23 '22 22:10

Silambarasan Poonguti


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.

like image 43
Tim Coker Avatar answered Oct 23 '22 23:10

Tim Coker


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.

like image 6
ferostar Avatar answered Oct 24 '22 00:10

ferostar