Add the onBackPressed() method to your activity. And super this. And when you click the back button on this.onBackPressed() . Update code for this:
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: this.onBackPressed(); return true; default: return super.onOptionsItemSelected(item); } } @Override public void onBackPressed() { super.onBackPressed(); }
source share