Screen orientation not resetting after phone is turned off (not shut down) On Android

My game is in landscape orientation and runs fine.  With the game running, If I turn off the phone and turn it on again the splash screen of the phone comes up in landscape mode.  I have to turn off my app for the phone’s splash screen to look normal again. 

Testing on Android 4.4.2 using Samsung Galexy 4s.  Corona Build V2014.2179

Here is my build file:

settings =
{
        orientation =
        {
                default = “landscapeRight”,
                content = “landscapeRight”,
                supported =
                    {
                            “landscapeRight”
                    },
        },
        
        android =
        {
            usesPermissions =
            {
                “android.permission.INTERNET”
            },
        },
 
        iphone =
        {
                plist =
                {
                        UIPrerenderedIcon = true
                },
        }
}

Here is what I use to suspend the game app in every lua file:


---------//  SUSPEND CODE FOR ANDROID  //-----------
local function onSystemEvent(event)
    if event.type == “applicationSuspend” then
        native.requestExit()
    end
end
Runtime:addEventListener(“system”, onSystemEvent)
-------// END SUSPEND CODE FOR ANDROID  //----------

Any ideas on why this behavior is happening, please let me know.  Am I doing somthing wrong?  Is this a bug in Corona?

Thank You, Jan Elmer

Update:  The Android phone runs another famous point-and-click game just fine.  This game was made in 2012 using Cornoa SDK is and is your ‘poster child’.  It obviously uses a much older version of Corona. When the phone is turned off (quick hit of the off button) and turned back on, the famous game comes up not suspended but running.   I am thinking the suspend code I was told to use is causing the problem?  

QUESTION:  For the code below:


---------//  SUSPEND CODE FOR ANDROID  //-----------
local function onSystemEvent(event)
    if event.type == “applicationSuspend” then
        native.requestExit()
    end
end
Runtime:addEventListener(“system”, onSystemEvent)
-------// END SUSPEND CODE FOR ANDROID  //----------

What is the difference between shutting the phone off (actually stand by mode) vs having the phone on and going to another app.  Is this code suppose to work when the phone is turned off VS the phone staying on and going to another app? 

This seems like a question for Joshua Quick.

Hi @jan0,

This isn’t my specialty per se, but I believe the “native.requestExit()” call is terminating your app outright, instead of just letting the OS “background” it. Try commenting out that line and see if the behavior is any different.

Best regards,

Brent

Thanks Brent,

I plan to try out your suggestion today.   I will let you know the outcome.  Thanks, Jan

Ok good news!  Removing the Android Suspend/exit code worked.  The game comes back up after I suspend the phone.  I think the problem is I was shutting down the APP (as Brent stated).

For best practice, I think it is best to let the user exit the app.  I notice this is the behavior with any app I start within Android.  Also I have heard that some apps are rejected “that purposely shutdown on a suspend”.  If any of this sounds incorrect, please let me know.

I will worry about iOS when I get there…

Thanks - Jan

THIS WAS REMOVED!!!

---------//  SUSPEND CODE FOR ANDROID  //-----------
local function onSystemEvent(event)
    if event.type == “applicationSuspend” then
        native.requestExit()
    end
end
Runtime:addEventListener(“system”, onSystemEvent)
-------// END SUSPEND CODE FOR ANDROID  //----------
 

Update:  The Android phone runs another famous point-and-click game just fine.  This game was made in 2012 using Cornoa SDK is and is your ‘poster child’.  It obviously uses a much older version of Corona. When the phone is turned off (quick hit of the off button) and turned back on, the famous game comes up not suspended but running.   I am thinking the suspend code I was told to use is causing the problem?  

QUESTION:  For the code below:


---------//  SUSPEND CODE FOR ANDROID  //-----------
local function onSystemEvent(event)
    if event.type == “applicationSuspend” then
        native.requestExit()
    end
end
Runtime:addEventListener(“system”, onSystemEvent)
-------// END SUSPEND CODE FOR ANDROID  //----------

What is the difference between shutting the phone off (actually stand by mode) vs having the phone on and going to another app.  Is this code suppose to work when the phone is turned off VS the phone staying on and going to another app? 

This seems like a question for Joshua Quick.

Hi @jan0,

This isn’t my specialty per se, but I believe the “native.requestExit()” call is terminating your app outright, instead of just letting the OS “background” it. Try commenting out that line and see if the behavior is any different.

Best regards,

Brent

Thanks Brent,

I plan to try out your suggestion today.   I will let you know the outcome.  Thanks, Jan

Ok good news!  Removing the Android Suspend/exit code worked.  The game comes back up after I suspend the phone.  I think the problem is I was shutting down the APP (as Brent stated).

For best practice, I think it is best to let the user exit the app.  I notice this is the behavior with any app I start within Android.  Also I have heard that some apps are rejected “that purposely shutdown on a suspend”.  If any of this sounds incorrect, please let me know.

I will worry about iOS when I get there…

Thanks - Jan

THIS WAS REMOVED!!!

---------//  SUSPEND CODE FOR ANDROID  //-----------
local function onSystemEvent(event)
    if event.type == “applicationSuspend” then
        native.requestExit()
    end
end
Runtime:addEventListener(“system”, onSystemEvent)
-------// END SUSPEND CODE FOR ANDROID  //----------