page navigation problem

hi

target platform: Android

i have 3 kind of pages : X , A , M

in X pages when user tap on Back key the program should end without warning. (works Fine)
in A pages when user tap on Back key the program shoud redirect to p3Main.lua

in M pages when user tap on Back key the program should show an overlay question to ask for exit or not

im using code below , but when i want to redirect from A pages to p3Main.lua the overlay pops up and fade itself befor going to p3Main.lua
not:p3Main.lua is a M type Page

its a global event in main.lua

function onKeyEvent( event ) if (event.keyName == "back") and (platformName == "Android") then if pname=="X" then native.requestExit() elseif pname=="A" then composer.gotoScene ( "p3Main", {effect=defaultEffect, time = defaultTime} ) elseif pname=="M" then options = { isModal = true, effect ="fade", time = 500, } composer.showOverlay( "p9Exit", options ) end return true end --return false end --==end of OnKeyEvent() Runtime:addEventListener( "key", onKeyEvent );

You definitely need to uncomment line 24.  Your logic looks pretty sound.

Rob

thanks for replay
what do you mean about "Your logic looks pretty sound. " my logic is good or bad? im not native english so cant understand some expressions.

line 24 is uncomented and no changes…
i think it is somthing to do with composer page life cycle , because when i remove the pname property from p3Main.lua wich is a M type Page , my problem goes a way , but new problem is , in p3Main.lua when user tap on back button notheng happes…

1 more question , a simple program with 9 forms and 4MB assets(database , images and… ) generates 11.5 MB apk file!!! . whay???
im using outlaw Editor , has same bugs but steel is the best

What is your native language?

Your logic looks good.   Can you post the code for your overlay scene?

thanks Rob
i found the problem
i forgot to check the “event.phase”
by changing line 3 to this:

if ( event.phase=="up")and (event.keyName == "back") and (platformName == "Android") then

code works fine .

actually im a asp.net C# programmer for a bout 3 years.
my native language is Persian, im from iran.
hopfully iran  and USA will shake hands soon and Corona Labs can reconsider about my partnership suggestion :wink:

what is your suggestion about Big Size of APK file??

 

We have to include more libraries for Android that we do iOS.  We also have to include items like SQLite that we get for free with iOS, but for Windows Phone 8 and Android, we have to include in the application.

Rob

You definitely need to uncomment line 24.  Your logic looks pretty sound.

Rob

thanks for replay
what do you mean about "Your logic looks pretty sound. " my logic is good or bad? im not native english so cant understand some expressions.

line 24 is uncomented and no changes…
i think it is somthing to do with composer page life cycle , because when i remove the pname property from p3Main.lua wich is a M type Page , my problem goes a way , but new problem is , in p3Main.lua when user tap on back button notheng happes…

1 more question , a simple program with 9 forms and 4MB assets(database , images and… ) generates 11.5 MB apk file!!! . whay???
im using outlaw Editor , has same bugs but steel is the best

What is your native language?

Your logic looks good.   Can you post the code for your overlay scene?

thanks Rob
i found the problem
i forgot to check the “event.phase”
by changing line 3 to this:

if ( event.phase=="up")and (event.keyName == "back") and (platformName == "Android") then

code works fine .

actually im a asp.net C# programmer for a bout 3 years.
my native language is Persian, im from iran.
hopfully iran  and USA will shake hands soon and Corona Labs can reconsider about my partnership suggestion :wink:

what is your suggestion about Big Size of APK file??

 

We have to include more libraries for Android that we do iOS.  We also have to include items like SQLite that we get for free with iOS, but for Windows Phone 8 and Android, we have to include in the application.

Rob