Orientation Not Recognized

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Orientation Not Recognized

Post by townsend » Sat Jul 09, 2011 9:36 pm

I'm using Ctl-F11 and Ctl-F12 to change the Simulator back and forth between Landscape and Portrait orientations. The Simulator changes orientation, but my app doesn't. I always stays in Portrait.

I checked the Android Lessons, and Release Notes. Nothing there about Orientation.

Actually, I want my app to be locked in Landscape orientation.
So when I do have the Simulator does go to Portrait, its should stay in Landscape--
and the the text appears sideways. (Left or Right? Can that be controlled?)

Anyone else have this problem? Or know what to do?
Last edited by townsend on Mon Jul 11, 2011 8:14 pm, edited 1 time in total.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: How to Lock Orientation

Post by BarrySumpter » Mon Jul 11, 2011 5:07 am

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:52 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Re: How to Lock Orientation

Post by townsend » Mon Jul 11, 2011 8:12 pm

Here's a simple 480x320, Hello World stack. Inside the button, I have:

Code: Select all

on orientationChanged
     answer mobileDeviceOrientation
end orientationChanged
119 orientation mixup.JPG
As you see, even when in landscape, LiveCode is reporting portrait.
The LiveCode stack is in fact in Portrait mode. It just doesn't know what the device is doing.

Also, I have this code in the Stack script, which never gets triggered.

Code: Select all

on orientationChanged
     answer mobileDeviceOrientation()
end orientationChanged
There isn't much to this stack. And-- I've tried it with different Simulator configurations.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Mon Jul 11, 2011 11:32 pm

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:52 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Re: Orientation Not Recognized

Post by townsend » Tue Jul 12, 2011 5:21 pm

Thanks Barry! Sometimes just asking the right questions is enough to point me in the right direction.
I've made some progress.

I'm uploading my Hello Word Testing program with all the Mobile commands behind buttons.
119 orientation mixup2.JPG
I spent few hours trying to figure out where and how to place all these Mobile Orientation commands with no success. Should they be in On PreOpenStack or in On Open Stack? I know the mobileSetAllowedOrientations("landscape right") is absolutely necessary, but I'm still unsure about the mobileLockOrientation and mobileUnlockOrientation commands. I've read through the Android Release notes on this many times. The nesting of lock and unlock commands is totally confusing.

My best guess, (does not work):

Code: Select all

on openstack
     if the environment is "mobile" then
          mobileUnlockOrientation
          mobileAllowedOrientations("landscape right")
          mobileLockOrientation
     end if
end openstack
Using the Android 2.3.3 API Level 10 with WQVGA400 resolution, my Get Current Orientation Button reports the wrong orientation in landscape. This Simulator never gets to proper landscape mode.

Using the Android 2.2 Simulator with WQVGA432 resolution, I have a glimmer of luck, but no where near a solution. After pressing the my Set Landscape button once, and repeatively doing a Ctl-F12, to toggle landscape mode in the Simulator, it eventually shows up in correct landscape mode. How to translate this into code, remains a mystery.

Note the Ctl-F11 Portrait and Crl-F12 Lanscape key combinations only work after you release both keys.
Attachments
Testing.zip
(1.54 KiB) Downloaded 315 times

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Wed Jul 13, 2011 12:14 am

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:52 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Wed Jul 13, 2011 1:52 am

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:53 pm, edited 3 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Wed Jul 13, 2011 3:05 am

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:53 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Orientation Not Recognized

Post by jacque » Wed Jul 13, 2011 3:47 am

Be careful of trying to use the orientationChanged message to determine the current orientation. That message is sent before any change occurs. If you are in portrait and you check orientation in an orientationChanged handler, it will return "portrait". The message you get after the display has changed is "resizeStack". If you check the orientation in that handler, it should reflect the post-changed (i.e., the current) orientation.

Orientation is typically set at preOpenStack, which is where you'd put the allowedOrientation command. I don't believe you need to lock the orientation at all if you are only allowing landscape orientations during preOpenStack.

That said, there may still be bugs in the implementation. I haven't tested it recently.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Wed Jul 13, 2011 4:46 am

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:54 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Re: Orientation Not Recognized

Post by townsend » Wed Jul 13, 2011 7:04 pm

I looked through your AndroidOrientationTest.livecode. It was a 432x544 portrait stack, pretty much similar to my Testing.livecode 230x432, landscape stack, except for the On PreOpenStack line for mobileAllowedOrientations. Barry-- I appreciate you looking into this for me. I've made some progress.
This is NO way, in LiveCode for Android, to force Landscape if in Portriat.
I kinda got that working but there is a LiveCode bug.
119 orientation mixup3.JPG
It works fine with the 2.2 Simulator, but NOT with any of the 2.3.1, 2.3.3 or 3.1 Simulators.
I could have sworn we had landscape working on the emulator with the Summer Academy example but I can't get it to work.
Yeah-- Elanor must have been using the 2.2 Simulator.
Orientation is typically set at preOpenStack, which is where you'd put the allowedOrientation command. I don't believe you need to lock the orientation at all if you are only allowing landscape orientations during preOpenStack.
Thanks Jacque-- that's exactly what I needed to know. Also-- good tip there about the orientationChanged message.

I still haven't gotten Windows 7 to recognize my Android phone, so I don't know how this will or won't work in actual use.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Wed Jul 13, 2011 11:26 pm

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:54 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Wed Jul 13, 2011 11:49 pm

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:55 pm, edited 2 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Re: Orientation Not Recognized

Post by townsend » Thu Jul 14, 2011 12:07 am

Just tried it again. Still works fine in 2.2 with the Skin setting to WQVGA432.

I have the mobileSetAllowedOrientations("landscape right") statement in On preOpenStack.

When the app starts the device is in landscape, but the app is in portrait, not good.
One click on Ctl-F12 and the device is in portrait, and the app is in landscape, not good.
One more click on Ctl-F12 and both device and app appear in landscape, good, after a couple of seconds.
The 3rd click on Ctl-F12 put the device in portrait, and the app still in landscape, the way it should be.

Clicking to the Home icon closes the app on the Simulator.
Then when I click the app, "TestingOrientation" icon from the Simulator's app list, the orientation remains where I last left it, which is good. So, it seems that the orientation problem only occurs after installation. Once it is set right, it stays that way.

I'm unable to test this on my device, so I have no idea how it run there. Either way, if the 2.3 and higher version don't work right, then it's problematic to release. And since we just got LiveCode 4.6.2, it will be another 3 months before the next update.
Attachments
TestingOrientation.zip
(1.8 KiB) Downloaded 343 times
Last edited by townsend on Thu Jul 14, 2011 12:45 am, edited 1 time in total.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Orientation Not Recognized

Post by BarrySumpter » Thu Jul 14, 2011 12:38 am

-
Last edited by BarrySumpter on Sun Sep 11, 2011 9:55 pm, edited 2 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply

Return to “Android Deployment”