public void finish ()
Call this when your activity is done and should be
closed. The ActivityResult is propagated back to whoever launched you
via onActivityResult().
finish()
is called to kill your activity instance after you did what you have to do with the activity. After that, you have no use with the activity. So simply call finish()
and it will kill your activity.
If you press back button, it will call finish()
automatically to kill the activity. It will go through the activity lifecycle(onPause()
, onStop()
and finally onDestroy()
)
The one reason with calling finish() is that, if you don't call it, when you navigate through activities, all the activities will be added to the backstack. So when you go back, you have to come back through these activities. So for e.g when you click back button, it simply kills the activity and it will be removed from the backstack.