how to override action bar back button in android?

I think you want to override the click operation of home button. You can override this functionality like this in your activity.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Toast.makeText(getApplicationContext(),"Back button clicked", Toast.LENGTH_SHORT).show(); 
        break;
    }
    return true;
}

Leave a Comment