how to check if toolbar back button is pressed in android activity code example
Example: android add back button to toolbar programmatically
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);