How to detect the orientation of device?

Login to reply to this topic.
Tue, 2007-01-16 14:54
Joined: 2004-07-09
Forum posts: 110
Hi,

My application supports only portrait mode, which I specified in BaseConstructL(EAppOrientationPortrait) in AppUi class.

I want to show up dialog when users switch from portrait to landscape mode.

I tried to used CAknAppUiBase::Orientation() function in HandleResourceChangeL function , But it gives me orientation of Application which is portrait.

How I detect the orientation of device when the orientation is changed from Portrait to Landscape.

Best Regards,
Dipak

DipakBaviskar


Wed, 2007-01-17 14:05
Joined: 2003-09-22
Forum posts: 27
Re: How to detect the orientation of device?
Hi,
I had a similar problem. To get over it I did the following..

HandleResourceChangeL(TInt aType)
{
CAknAppUi::HandleResourceChangeL( aType );
       
    if ( aType==KEikDynamicLayoutVariantSwitch )
    {...}

}

However I could not reliablytell the current orientation so I used the function
TSize size; AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EScreen, size);

In general on most devices that I know of the width in portrait is always less than landscape and the height is always greater than landscape. In this fashion you can determine the layout.
Brian
Thu, 2007-03-08 18:13
Joined: 2006-10-23
Forum posts: 36
Re: How to detect the orientation of device?
hi, try this

CWsScreenDevice& iScreen = *(iCoeEnv->ScreenDevice());

TSize res = iScreen.SizeInPixels();

                                                        //"res" now cintent the actual resolution.....

TSize visuale1(176,208);
    TSize visuale2(208,176);
    TSize visuale3(240,320);
    TSize visuale4(320,240);
    TSize visuale5(352,416);
    TSize visuale6(416,352);
if (res == visuale1)
     {
           // add code...............
     }
:
: ecc;

  • Login to reply to this topic.