Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between actionBar back button and android back button

What is the difference between actionBar back button and android back button? Because it's seems that the ActionBar back button which is called with:

ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

it works way better...

example: when I press the ActionBar back button the animations are there, but if I press the default back button they aren't.

I can change theme from a preference activity: If I go back with the ActionBar back button the colors instantly changed, but with the default I have to restart the app....

how can I make my default back button to behave like the ActionBar one?

like image 518
Csabi Vidó Avatar asked Dec 03 '14 21:12

Csabi Vidó


People also ask

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

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.

How do you display action bar back button on all versions of Android?

Show back button using actionBar. setDisplayHomeAsUpEnabled(true) this will enable the back button. Custom the back event at onOptionsItemSelected. This will enable the back function to the button on the press.

How do I get rid of the back arrow on my Android toolbar?

getActionBar(). setDisplayShowHomeEnabled(false); //disable back button getActionBar(). setHomeButtonEnabled(false); In a older android phone, the back button is removed with these two code lines.


2 Answers

The android back button navigates "back". The nav bar button navigates "up". Up navigation always leads you to the same app you were on, just a different activity. Back can change app AND activity.

like image 92
MeetTitan Avatar answered Oct 01 '22 22:10

MeetTitan


The ActionBar "back" button is actually an "Up" button and it should take you to higher level on your app's navigation hierarchy. The back button takes you to the last place you were looking at.

Another great tip to better undertand this is that the "Up" button should always take you to a place on your app, while the back button might take you to another app.

You might want to read this article to better understand the difference: http://developer.android.com/design/patterns/navigation.html

like image 33
Julian Suarez Avatar answered Oct 01 '22 22:10

Julian Suarez