Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Force App to stay in Landscape Mode

Good evening,

you helped me once and I hope you can help me again. I want my app to stay in landscape mode, even when the phone's turned again. I'm not sure if it's possible to start an app in landscape mode directly but as far as I've read through the Q&A, there's isn't a way to do that…

I have the following code:

var win = Titanium.UI.createWindow();
win.orientationModes = [ Titanium.UI.LANDSCAPE_LEFT ];

Then if I turn my phone to the left, the view is in the landscape mode, which is just fine, but then I want it to keep that mode but if I turn it again it switches to portrait mode. How can I prevent this?

I actually don't have a clue how to solve this problem. Sorry if it's an obviously stupid question but I hope you can help me out with this.

I'm running the script on an HTC Legend.

Thanks,

Michael

— asked May 25th 2010 by Michael Ziörjen
  • android
  • landscape
  • orientation
0 Comments

6 Answers

  • Try

    // Set orientation
    Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT; //or _RIGHT
    

    This should go on every window (or JS) you have.
    Hope it helps.

    — answered May 25th 2010 by Edwin Huertas
    permalink
    0 Comments
  • Thanks for your answer, but I couldn't solve the problem with that line of code. The app is still switching to portrait mode if I turn the phone. It starts in portrait mode too… Argh isn't there any way to solve this? This is really one thing that's blocking my whole app…

    Thanks,

    Michael

    — answered May 26th 2010 by Michael Ziörjen
    permalink
    0 Comments
  • I have to agree, I have an App that needs to stay portait.

    win2.orientationModes = [ Titanium.UI.PORTRAIT ];
    

    That doesn't do anything, It's more than happy to rotate.
    It doesn't make a difference if it's before or after the window.open, I'd try declaring it before the window, but that's just silly.

    Oh it's HTC Hero by the way, Running an official 2.1

    — answered June 9th 2010 by Ryan Tregea
    permalink
    3 Comments
    • Which version of Titanium? Release 1.3?

      — commented June 9th 2010 by Don Thorp
    • Yeah 1.3, Found Ticket

      — commented June 9th 2010 by Ryan Tregea
    • It's a chicken and egg problem with Android Activites. We're look at ways to make this more stable on Android in general.

      — commented June 11th 2010 by Don Thorp
  • does forcing Portrait in Android work yet? if so…how do we accomplish it?

    — answered July 12th 2011 by Brian Dittmer
    permalink
    1 Comment
    • http://developer.appcelerator.com/question/40001/android-force-orientation

      I just tried and succeed with that tip

      — commented July 20th 2011 by Nary Razafintsalama
  • a

    — answered October 17th 2013 by aoeu snth
    permalink
    0 Comments
  • https://developer.appcelerator.com/question/4981/how-to-set-landscape-mode has the answer.

    For making the setting persist between program starts, use app properties http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.App.Properties

    — answered October 17th 2013 by aoeu snth
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.