Actionbarsherlock back button and smartphone back button

自作多情 提交于 2019-12-04 21:47:10

In your Second Activity just remove your intent and startActivity stuff. Only need:

case android.R.id.home:
    finish();
break;

finish() will remove that activity from the back-stack so don't use it when starting a new activity that you want the user to get back to by pressing the back button.

You do not want to relaunch you Principal activity from SecondActivity, you just want the second activity to finish and return to the previous activity. Try replacing the following code in SecondActivity --

Intent intent = new Intent(this, Principal.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);

with just finish().

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