开发者

air android app always launches in portrait mode irrespective of the way the android device is held ( landscape/portrait)

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 开发者_如何学Con this problem ?

thanks


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         
}


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


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);
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜