How to detect the orientation of device?
| Tue, 2007-01-16 14:54 | |
|
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 |
|






Forum posts: 27
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
Forum posts: 36
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;