You can use this method to trigger something when the home or "up/back" button in the actionbar is pressed.

For example, save what the user is currently doing or writing.

actionbar-home

You can listen for the Home button pressed event in the optionsItemsSelected method:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home: {
            doSomething();
            return true;
        }
    }
    return super.onOptionsItemSelected(item);
}

Returning true after executing your method, "consumes" the event, so it does not propagate further.

More information on Actionbar home button, and optionItemsSelected can be found here and here.