1
votes

i have an AIR android app which i am running on an android device ( samsung TAB ). i want the app to get laid out in landscape mode when the user starts the app holding the device in landscape ( same goes with portrait ).

but the AIR app always gets started in portrait mode irrespective of the way the device is held.

i tried the following ways -

  1. use stage.deviceorientation (but when the app starts (after the applicationComplete notification ) the value is UNKNOWN)

  2. use stage resize event. (this gets triggered at start itself, a manual resize is not required - the values are based on portrait mode though - the width is 600 and height is 1024 (should have been otherway) )

i get correct values when i try changing the orientation of device, only at the startup i see problem with the required values.

could you please advice on this problem ?

thanks

3

3 Answers

0
votes

Use getResources().getConfiguration().orientation.

Link here

if(myCurrentActivity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) 
{
    // code to do for Portrait Mode
} else {
    // code to do for Landscape Mode         
}
0
votes

Even though I dont have an answer... I'd just to like to point out... the response from Nguyen is completely irrelevant... This question was about AIR, not native Android dev

though... you may want to look into stage.orientation instead of stage.deviceOrientation

0
votes

Try this in your application activation handler:

NativeApplication.nativeApplication.addEventListener(flash.events.Event.ACTIVATE, function (e:*):void{

    if(stage.orientation == StageOrientation.UNKNOWN){
        stage.setOrientation(StageOrientation.ROTATED_LEFT);
    }
});