I am in details activity and I want to return to the home activity , what is the difference between pressing back button and calling finish method on details activity ?
It means that Back button kills an app whereas Home button sends an app to background (Android memory manager can still choose to kill it if system runs out of memory).
Up and Back are identical within your app's task When you press the Back button, the current destination is popped off the top of the back stack, and you then navigate to the previous destination. The Up button appears in the app bar at the top of the screen.
All Android devices provide a Back button for this type of navigation, so you should not add a Back button to your app's UI. Depending on the user's Android device, this button might be a physical button or a software button.
However, when the back button is pressed, the activity is destroyed, meaning, the temporary data is lost during this call. This is what the official documentation states. But we do not want to lose this data. To retain the data, we need to override the back pressed method.
If you have not Override onBackPressed()
method from your Activity
then, it will invoke finish()
for your Activity
. You don't need to call finish()
explicitly..
So by that it will display Activity
which is in the top of the Activity Stack
. And there is empty Stack
then you will quite from the application.
If you have Override onBackPressed()
method then You have to call finish()
explicitly to destroy activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With