Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between back button and finish ?

Tags:

android

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 ?

like image 346
Mohammed Subhi Sheikh Quroush Avatar asked Jan 31 '13 18:01

Mohammed Subhi Sheikh Quroush


People also ask

What is the difference between back button and home button?

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).

What is the difference between the up button and back button?

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.

Do All Android devices have a back button?

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.

What happens when back button is pressed in Android?

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.


1 Answers

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.

like image 89
Pratik Sharma Avatar answered Sep 23 '22 07:09

Pratik Sharma