The following code causes a back arrow to appear in the ActionBar:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsU
The id of the back button in Toolbar is
android.R.id.home
You can take action from onOptionsItemSelected Method on Activity.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
//Do your task here.
return true;
}
return super.onOptionsItemSelected(item);
}