×
Namespaces

Variants
Actions
(Difference between revisions)

Retrieving current orientation of a device in WRT

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Automated change of category from Web Runtime (WRT) to Symbian Web Runtime)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
__NOEDITSECTION__
 
__NOEDITSECTION__
{{CodeSnippet
+
{{ArticleMetaData
 
|id=
 
|id=
 
|platform=S60 5th Edition
 
|platform=S60 5th Edition
Line 9: Line 9:
 
|creationdate=December 25, 2008
 
|creationdate=December 25, 2008
 
|keywords=device.getServiceObject(), Service.SysInfo, Service.SysInfo.GetInfo()
 
|keywords=device.getServiceObject(), Service.SysInfo, Service.SysInfo.GetInfo()
 +
 +
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
 +
|author=[[User:Kiran10182]]
 
}}
 
}}
  

Revision as of 11:45, 24 June 2011


Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Platform Security
Capabilities: )
Article
Keywords: device.getServiceObject(), Service.SysInfo, Service.SysInfo.GetInfo()
Created: kiran10182 (25 Dec 2008)
Last edited: hamishwillee (24 Jun 2011)

Overview

This code snippet demonstrates how to obtain the Display Orientation of a device by using the SystemInfo Service API of the Web Runtime (WRT) 1.1.

Note: The SystemInfo Service API for WRT 1.1 is only available from S60 5th Edition onwards.

Source file: index.html

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="basic.js"></script>
<script type="text/javascript" src="WRTKit/WRTKit.js"></script>
<style type="text/css">
@import url("basic.css");
</style>
</head>
<body onload="init()">
</body>
</html>

Source file: basic.js

var systemServiceObj = null;
 
// Called from the onload event handler to initialize the widget.
function init()
{
try
{
systemServiceObj = device.getServiceObject("Service.SysInfo", "ISysInfo");
}
catch (ex)
{
alert("System Service object cannot be found.");
return;
}
getDisplayOrientation();
}
 
// Display Information
function getDisplayOrientation()
{
// Initialize the criteria for the service object and obtain the
// information
var criteria = new Object();
criteria.Entity = "Display";
criteria.Key = "DisplayOrientation";
try {
var result = systemServiceObj.ISysInfo.GetInfo(criteria);
}
catch (ex)
{
alert(ex);
return;
}
 
alert("Current Display Orientation: " + result.ReturnValue.Status);
}

Postconditions

  • Display Orientation of a device will be displayed on the screen in the range of 0 - 3.

Supplementary material

59 page views in the last 30 days.
×