Android Back Navigation Problems

I’m having problems with the Android Back key. I’ve tried almost everything I can think of, I thought I found some ways that worked, but I apparently not. No matter what scene I’m in, the back button will only bring me back to the main menu, rather than the previous scene like it should.
 

I’ve looked at the API, I’ve looked at http://www.coronalabs.com/blog/2013/03/26/androidizing-your-mobile-app/ … and the “Example Code” does nothing but show how worthless it can be.

A map of my app…

Menu > Menu2 > Tutorials > Tutorial1

Tutorials should go back to Menu2 , Tutorial1 should go back to Tutorials , but both go back to Menu.

I have this function below in all of my scenes with their respective “changeScene”'s to go back to the previous screen; but as I mentioned, ALL bring me back to the main menu.

local function moveBack() Runtime:removeEventListener("key", onKeyEvent) display.remove(allObjects);allObjects=nil director:changeScene("previousScene", "crossfade") end local function onKeyEvent( event ) local returnValue = true if (event.phase=="up" and event.keyName=="back") then timer.performWithDelay(100,moveBack,1) end return returnValue end Runtime:addEventListener( "key", onKeyEvent )

This is making me pull my hair out, I’ve been working on it for a good 2 months now and it’s the only thing preventing me from publishing my app.

Hi! I have the same problem!! If somebody could help us, will be great!!

Follow this logic.  Scene A goes to Scene B.

what is the previous scene?  Scene A right?

Okay, Scene B now goes to Scene C

what is the previous scene?  Scene B.  All is good.  Now goto your previous Scene, which is Scene B.

What is the previous scene?  Scene A?  No.  It’s Scene C.  Going to the previous Scene goes to Scene C.  Now Scene B is previous. Go there, Scene C is now the previous.

You have to setup your own “stack” (an array of previously visited scenes) and then use a regular goto scene instead of previous scene to go where you want.

Hi! I have the same problem!! If somebody could help us, will be great!!

Follow this logic.  Scene A goes to Scene B.

what is the previous scene?  Scene A right?

Okay, Scene B now goes to Scene C

what is the previous scene?  Scene B.  All is good.  Now goto your previous Scene, which is Scene B.

What is the previous scene?  Scene A?  No.  It’s Scene C.  Going to the previous Scene goes to Scene C.  Now Scene B is previous. Go there, Scene C is now the previous.

You have to setup your own “stack” (an array of previously visited scenes) and then use a regular goto scene instead of previous scene to go where you want.