iheanyi iheanyi - 1 year ago 66
Android Question

NullPointerException Android ActionBar Back (but not Menu Bar Back)

I get an error with the ActionBar back button when I'm moving back to a previous activity, but when I use the Menu Button Back, everything works as planned! I think I have an idea of what is going on, because using the Action Bar back button causes a recreation of the previous activity, but I don't want that to happen. How do I override the Action Bar (default) back button to perform like the Menu Bar back button so that OnDestroy() is not called?

Answer Source

I figured it out, I had to call finish() in my onMenuItemClicked function rather than using the default function.