Difference between actionBar back button and android back button

浪尽此生 提交于 2019-12-04 05:06:19

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

In Activity B:

@Override
    public void onBackPressed()
    {
        NavUtils.navigateUpFromSameTask(this);
        super.onBackPressed();
}

The parent activity must be specified in the manifest file. See also https://developer.android.com/training/implementing-navigation/ancestral.html

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.

By an example:

Go to the Gmail app, start to reply to an email by typing the message, don't send. just now:

  • if back button pressed → only the keyboard will be closed.
  • if Up button pressed ---→ both keyboard and reply activity will be closed.

► Back button has working with back stack ..... and not related with specific app.
► Up button has working with app's hierarchy .. and related with specific app.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!