2

I have a small problem with my Android app. Within my control XML i have

<autoOrients>false</autoOrients>
<aspectRatio>landscape</aspectRatio> 

and this works also on the first start of the application. The app starts in landscape mode and everything works perfectly. Then, i click the home button (or the phone goes to standbye mode). Now i select the application from the tasklist or click the application icon. The application is now in portrait mode (for which he is not designed for) and since i have disabled the autoOrients, i cannot switch back to landscape mode.

Is this a bug in Flex 4.6 (i work with Adobe Flash Builder 4.6) or is there some other switch missing?

Best regards KjM

3 Answers3

0

I was running into similar issues; I believe with some versions of Android. I added code like this to my main application file. It uses the applicationComplete and the activate events to set the aspect ratio of the app at runtime. It is a backup for when the descriptor setting gets wonky.

<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                            xmlns:s="library://ns.adobe.com/flex/spark" 
                            firstView="something"   
applicationComplete="viewnavigatorapplication1_applicationCompleteHandler(event)"
activate="viewnavigatorapplication1_activateHandler(event)">

    <fx:Script>
        <![CDATA[

            import mx.events.FlexEvent;


            protected function viewnavigatorapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                this.stage.setAspectRatio( StageAspectRatio.LANDSCAPE );
            }

            protected function viewnavigatorapplication1_activateHandler(event:Event):void
            {
                if(this.stage){
                    this.stage.setAspectRatio( StageAspectRatio.LANDSCAPE );
                }
            }

        ]]>
    </fx:Script>
JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
0

add

<activity
            android:name="xxxx"
            android:label="xxxxx"
            android:screenOrientation="landscape" >

to your activity tag in the manifest

Simo
  • 1,200
  • 1
  • 16
  • 26
  • He is using Flex/AIR. I'm pretty sure that the Android Manifest is created behind the scenes by the AIR Compiler; based on his Flex/AIR Application Descriptor file. I'd guess that the aspectRatio element he specifies will translate into screenOrientation; but I don't actually know that. I think he could add this in the manifestAdditions section of his app descriptor; but he shouldn't have to. – JeffryHouser Apr 03 '13 at 17:20
  • Yes, thats correct. The compiler throws and error about unbound element :( – Kai-jens Meyer Apr 04 '13 at 13:29
0

Enter the following values in your main-app.xml

<aspectRatio>portrait</aspectRatio>
<autoOrients>false</autoOrients>

Your Mobile App will start now with the portrait aspect ratio, regardless the orientation of the mobile device. Your app will ignore now the rotation of your mobile device.

Stefan
  • 5,203
  • 8
  • 27
  • 51
guest
  • 1