Skip navigation
Rob_2006
Currently Being Moderated

AIR for Android - landscape mode

Feb 3, 2011 2:05 AM

Hi All,

 

I have trouble starting my AIR application in landscape mode on a htc desire. The app does not start in landscape mode and the device orientation is ignored as well.

 

 

My air app has width of 800 and height of 480 pixels.

That's defined in my meta tag:

[SWF(backgroundColor="#000000", frameRate="30", quality="HIGH", width="800", height="480")]

 

I also edited the application descriptor file:

<renderMode>gpu</renderMode>

<fullScreen>true</fullScreen>

<aspectRatio>landscape</aspectRatio>

<autoOrients>true</autoOrients>

 

Everything seems to be ignored. My app is displayed in portrait mode scaled  centred and with large black bars.

 

Am I missing something here?

 

 

Cheers

 

 

Robin

 
Replies
  • Currently Being Moderated
    Feb 3, 2011 3:14 AM   in reply to Rob_2006

    Hi Rob 2006

    What you are missing is in Flash Profession CS5:

     

    1. Select the Air Android setting in the properties panel
    2. In the General tab check Full Screen
    3. Select the Aspect Ratio tab and select Landscape and compile.

     

    When you view on your HTC Desire it will be the right orientation with no black boarders

     

    Hope this help.

     

    regards Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 3, 2011 9:29 AM   in reply to Rob_2006

    Robin,

     

    Set your "autoOrients" to false and the app should start/stay in landscape mode.  Try that first and let me know if it works.

     

    Next, to get autoOrient working so the device adapts depending on whether it is held vertical/horiztonal, you need to do the following:

     

    1) Renable the "autoOrients" option

     

    2) Set stage properties as follows:

     

    stage.align = StageAlign.TOP_LEFT;

    stage.scaleMode = StageScaleMode.NO_SCALE;

     

    3) Add listener events for the stage resizing:

     

    stage.addEventListener(Event.RESIZE, resizeHandler);
    stage.dispatchEvent(new Event(Event.RESIZE));

     

    function resizeHandler(e:Event):void{
       if(stage.stageWidth > stage.stageHeight){
        orientHorizontal();     //Write a custom function that repositions your display objects for horizontal viewing
       }
       else{
         orientVertical();       //Write a custom function that repositions your display objects for vertical viewing
       }

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 3, 2011 9:36 AM   in reply to Rob_2006

    If my above solution doesn't work, it's possible that there may be a bug specifically with HTC Desire running landscape mode in AIR.

    See the following similar post from another user: http://forums.adobe.com/message/3446162#3446162.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 3, 2011 1:55 PM   in reply to RossD20Studios

    This is baffling to me as I have an HTC Desire and I am sure this works.

     

    In fact I just made an APK using the CS5 Android extension. It uses no code and has 'landscape' set in the auto-generated app-xml.

     

    When I load it on my phone the orientation is landscape and I have to rotate my phone to read it properly. If I change the xml to portrait then it comes up in portrait as expected.

     

    It is here if you want to try: http://www.coldwired.com/orient.apk

    (i'm going to delete this after a few days)

     

    It is simply a textfield with the word 'TEST' inside, placed on the stage.

     

    How does it come up on your phone?

     

    Nick

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 4, 2011 3:20 AM   in reply to Rob_2006

    Hi Robin,

     

    Here's something else you could take a look at, just to be sure:

     

    If you go and get a tool like apktools http://code.google.com/p/android-apktool/ then you can deconstruct the apk and open the android manifest xml and make absolutely sure the aspect ratio is set to 'landscape' in the finished product.

     

    Then we'll know whether or not something is going wrong during the build.

     

    Or if you want to post the apk I'll do it?

     

    Nick

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 4, 2011 4:27 AM   in reply to Rob_2006

    I think we're getting somewhere now.

     

    I tested your apk on my phone and it opened in portrait mode.

     

    So I used apktool to decode the apk and I took a look at the android manifest xml, and it seems to be missing some stuff. (To clarify, this is the android manifest xml, not the app xml).

     

    I'm not familiar with what should and shouldn't be there so I may be barking up the wrong tree, but a typical android manifest xml file would contain a few lines like this example:

     

    <meta-data android:name="aspectRatio" android:value="landscape" />
    <meta-data android:name="autoOrients" android:value="false" />
    <meta-data android:name="fullScreen" android:value="true" />

     

    It gets that data from the settings in the app xml (the one that we include in the build). I can see your app xml too and it's all correct, you have set up the landscape aspect ratio. I have no idea why it is not making it into the completed apk.

     

    So anyway, I suspect the app is reverting to portrait mode when it starts because that's the default aspect ratio when none is specified.

     

    I will think about this a bit more, but I need some lunch now!

     

    Nick

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 4, 2011 6:55 AM   in reply to Rob_2006

    That sounds strange that you would get an error. To give you some perspective, the CS5 extension creates an empty manifestAdditions tag, rather than commenting it out.

     

    I just use a cutdown one in my apps, like this:

     

      <android>
        <manifestAdditions>

          <![CDATA[<manifest android:installLocation="auto">
    <uses-permission android:name="android.permission.INTERNET"/>
    </manifest>]]>
        </manifestAdditions>
      </android>

     

    You want to give that a try and recomplile your apk? I don't see why this would affect the aspectRatio, but maybe they are symptoms of the same problem.

     

    On a separate note, the manifestadditions that you have commented out in your apk has this line in it:

     

    <uses-configuration android:reqFiveWayNav="true"/>

     

    And that would prevent your app showing up in the marketplace on any device without a trackball. The HTC Desire has one, but a lot of other phones don't.

     

    Nick

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 5, 2011 9:03 PM   in reply to Rob_2006

    Hello All,

     

    I've been having the same issue as Rob - in the end, I just built my app in portrait, but for future apps, especially games, I really want to be able to use landscape.

     

    From reading this thread, there seems to be an error when compiling the apk and the <landscape> tag somehow gets changed back to <portrait>. I don't think it's a problem with coding or the application XML since I tried this and had the same issue with a Hello World grade test app. However, if it's not a phone issue, is it just coincidence that both Rob and myself have HTC Desires?

     

    I'll be following this post and I'll also post my findings when I get a chance to work on it sometime next week.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 7, 2011 2:27 PM   in reply to Rob_2006

    I've tried compiling it via ADT with AIR 2.5 and it opened in landscape mode as normal.

     

    Then I tried copying and pasting in your app xml from above, swapping the filenames and re-compiling. This time it opened in portait mode and I thought I'd managed to recreate the issue.

     

    Then I saw <autoOrients> is set to true. As soon as I set that to false, it opened in landscape mode.

     

    So I think that all along it's been opening in landscape and immediately re-orientating itself to portrait? This is unusual on my phone because I have auto-orientation switched off at an OS level, but still that would explain everything.

     

    Can you try setting <autoOrients> to false?

     

    If that's not it, then I think whatever is causing the error with the manifest additions on your system is responsible. It compiled fine with manifestAdditions for me.

     

    Nick

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 8, 2011 2:02 AM   in reply to Rob_2006

    Yep, here you go:

     

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <application xmlns="http://ns.adobe.com/air/application/2.5">

     

      <id>orient</id>

     

      <versionNumber>1.0.0</versionNumber>

     

      <versionLabel/>

     

      <filename>orient</filename>

     

      <description/>

     

       <name>orient</name>

     

      <copyright/>

     

      <initialWindow>
        <content>orient.swf</content>
        <systemChrome>standard</systemChrome>
        <transparent>false</transparent>
        <visible>true</visible>
        <fullScreen>true</fullScreen>
        <aspectRatio>landscape</aspectRatio>
        <renderMode>cpu</renderMode>
        <autoOrients>false</autoOrients>
      </initialWindow>

     

      <icon/>

     

      <customUpdateUI>false</customUpdateUI>

     

      <allowBrowserInvocation>false</allowBrowserInvocation>

     

      <android>
        <manifestAdditions>

          <![CDATA[<manifest>
    </manifest>]]>
        </manifestAdditions>
      </android>

    </application>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2011 2:47 AM   in reply to Rob_2006

    Hello Robin and All,

     

    Remember I was having the same problem? I tracked it down at last and fixed it.

     

    You said that you thought the problem was with Flash Builder and it was fixed when you switched to Flash CS5. This struck me as odd because I had been using Flash CS5 and having this issue. Actually, the problem was with the extension.

     

    I had installed the extension: AIRforAndroid_FlashCS5_070510.zxp which shows up in the extension manager as AIR for ANDROID pre-release. The problem was with this file. (You don't get any kind of prompt when a newer version is available.)

     

    I downloaded the latest one to replace it (flashpro_extensionforair_p2_112210.zxp) and now it works perfectly.

     

    Robin, when you switched to Flash CS5 from FlashBuilder, you mentioned that you downloaded a new extension. This is what fixed your problem as far as I can see.

     

    I hope this post helps out anyone with the same issue.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2011 2:51 AM   in reply to Rob_2006

    Hello Robin and All,

     

    Remember I was having the same problem? I tracked it down at last and fixed it.

     

    You said that you thought the problem was with Flash Builder and it was fixed when you switched to Flash CS5. This struck me as odd because I had been using Flash CS5 and having this issue. Actually, the problem was with the extension.

     

    I had installed the extension: AIRforAndroid_FlashCS5_070510.zxp which shows up in the extension manager as AIR for ANDROID pre-release. The problem was with this file. (You don't get any kind of prompt when a newer version is available.)

     

    I downloaded the latest one to replace it (flashpro_extensionforair_p2_112210.zxp) and now it works perfectly.

     

    Robin, when you switched to Flash CS5 from FlashBuilder, you mentioned that you downloaded a new extension. This is what fixed your problem as far as I can see.

     

    I hope this post helps out anyone with the same issue.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points