Detecting Actionbar Home button press event

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.


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

public boolean onOptionsItemSelected(MenuItem item) {  
    switch (item.getItemId()) {
        case {
            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.

comments powered by Disqus