mobileSetAllowedOrientations

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

mobileSetAllowedOrientations

Post by paulsr » Fri Jan 31, 2014 10:25 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: mobileSetAllowedOrientations

Post by jacque » Fri Jan 31, 2014 6:47 pm

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"
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: mobileSetAllowedOrientations

Post by paulsr » Sat Feb 01, 2014 5:27 am

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

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: mobileSetAllowedOrientations

Post by MaxV » Mon Feb 03, 2014 4:17 pm

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?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: mobileSetAllowedOrientations

Post by paulsr » Tue Feb 04, 2014 3:07 am

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

Post Reply