언어 설정

Menu
Sites
Language
Device orientation listener

Hello,

Can we determine that the application is in portrait or landscape orientation?

Responses

2 댓글
konduri sai swathi

Hi,

Try the below code :

function onSuccessOrientationCallback(orientation)
{
    switch(orientation.status)
	{
	case 'PORTRAIT_PRIMARY':       
	case 'PORTRAIT_SECONDARY':
	console.log("Portrait");
		break ;
	case 'LANDSCAPE_PRIMARY':
	case 'LANDSCAPE_SECONDARY':
	console.log("Landscape");
		break ;      
	}
	var orientationStatus = orientation.status.toLowerCase();
	orientationStatus = orientationStatus.replace('_', '-');
	console.log("orientation.status " + orientationStatus);
	screen.unlockOrientation();
	screen.lockOrientation(orientationStatus);
}

Place below code inside init()

tizen.systeminfo.addPropertyValueChangeListener("DEVICE_ORIENTATION", onSuccessOrientationCallback, function(){}, {});
tizen.systeminfo.getPropertyValue("DEVICE_ORIENTATION", onSuccessOrientationCallback, function(){})

 

Alexander AVSukhov

Hello,

You may use Screen Orientation API:

http://www.w3.org/TR/2012/WD-screen-orientation-20120522/