Search code examples
androidandroid-appbarlayout

Up Button without specific parent


I have one activity "X" which can be called from multiple activities "A", "B" "C" . I'd like to implement the Up Button in the Appbar so that it behaves like the backbutton on a phone.

Meaning: If one hit the Up button in activity "X" the user should go back to the activity "A" when activity "X" is called from activity "A". Hope the usecase is clear ;-)

If I try to use the method form that post:

Multiple Activities and Up Button

Android Studio tells me, I can't override the onMenuItemSelected method because its final.

Is there away around? Or a better way to do this?

Thanks for any help or hint.


Solution

  • Your onMenuItemSelected is coming up final so I guess you are using ActionBarActivity. If yes, try extending onOptionsItemSelected. That method isn't final in that class.