Page 1 of 1

mobileSetAllowedOrientations

Posted: Fri Jan 31, 2014 10:25 am
by paulsr
Greetings:

Would I be correct in thinking that mobileSetAllowedOrientations does not work on Android devices?

I have an app that I want to open in landscape mode. I've tried...

Code: Select all

mobileSetAllowedOrientations ("landscape left,landscape right")


...and...

Code: Select all

mobileSetAllowedOrientations "landscape left,landscape right"


...but the app always opens in portrait mode. This works fine on iOS devices.

I've searched the forum and can find some messages which allude to a problem, but I can't find a definitive answer.

If mobileSetAllowedOrientations doesn't work, is there some other way to force a device into landscape?

I'm using LC6.5.2 and have tried with a number of AVDs. I don't currently have a physical Android device.

Many thanks...

--paul

Re: mobileSetAllowedOrientations

Posted: Fri Jan 31, 2014 6:47 pm
by jacque
I haven't built for Android with the latest LiveCode but it's always worked in the past. But the orientation can't be controlled until after your app loads, so the initial orientation is controlled by the embedded manifest, which you can set in the Android pane of Standalone Settings. Once the app is in RAM, scripted settings are honored after that. You should set the allowed orientations in a preOpenStack handler, or a preOpenCard handler on the first card, so that it activates before the stack is shown.

Don't use the parentheses version, use the one where the orientations are enclosed by quotes:

mobileSetAllowedOrientations "landscape left,landscape right"

Re: mobileSetAllowedOrientations

Posted: Sat Feb 01, 2014 5:27 am
by paulsr
jacque wrote:...so the initial orientation is controlled by the embedded manifest, which you can set in the Android pane of Standalone Settings....
Hmm, feeling stupid again. I looked at the Settings for iOS devices, which has the four checkboxes ... then I looked at the Android Settings. No checkboxes. Never noticed the "Initial Orientation" dropdown!

It's set to portrait by default, and I guess whatever I put in LC does not override that. Setting it to landscape solved my problem.

Thanks Jacqueline...

--paul

Re: mobileSetAllowedOrientations

Posted: Mon Feb 03, 2014 4:17 pm
by MaxV
File->Stand Alone Application Settings.. -> Android-> Initial orientation works for me.

If I don't put:

Code: Select all

On preOpenStack
   if the environment is "mobile" then
      mobileSetAllowedOrientations    "portrait,portrait upside down,landscape left,landscape right"
   end if   
end preOpenStack
My app doesn't rotate

Did you try to rotate your mobile device?

Re: mobileSetAllowedOrientations

Posted: Tue Feb 04, 2014 3:07 am
by paulsr
No, I didn't try that Max, because I want to lock the app into one of the landscape orientations when it opens.

It is for use in a moving (competition) vehicle, and I don't want the orientation to change dependent the vehicle's movement, even if it rolls!

I'll see if I can try it on another app tho I always use mobileSetAllowedOrientations in all apps.

--paul