Namespaces
Variants
Actions

Archived:Checking for S60 Platform Services support in Symbian Web Runtime

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata

Code Example
Tested with
Devices(s): Nokia 5800, S60 3rd Edition FP2 devices

Compatibility
Platform(s): S60 5th Edition (initial release), S60 3rd Edition FP2

Article
Keywords: WRT widget S60 Platform Services JavaScript
Created: petrosoi (12 Oct 2008)
Last edited: hamishwillee (01 Aug 2012)

Contents

Overview

Access to device resources from a WRT widget via S60 Platform Services is currently only supported in S60 5th Edition.

Here's the code for a simple widget, checking the existence of the JavaScript device object extension.

Preconditions

S60 3rd Edition FP2 or S60 5th Edition emulator is needed for testing.

Widget HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My Location Aware Widget</title>
<script type="text/javascript">
window.onload = function() {
 
var serviceObject;
try{
serviceObject = device.getServiceObject("Service.Location", "ILocation");
}
catch(e){
if( e.name == 'ReferenceError' )
alert('device object cannot be found');
else
alert(e);
return;
}
 
try{
var criteria = new Object();
var result = serviceObject.ILocation.GetLocation(criteria);
 
var latitude = result.ReturnValue.Latitude;
var longitude = result.ReturnValue.Longitude;
 
alert('Latitude= ' + latitude + '\nLongitude= ' + longitude);
}
catch(e){
alert(e);
}
};
</script>
</head>
<body>
</body>
</html>


Postconditions

If the device object exists, the widget pops up an alert box with the latitude and longitude acquired from the active positioning system on the device.

Otherwise an alert box with the text 'device object cannot be found' is shown to the user.

Please note that the GetLocation call used in this example is synchronous and may block your widget for a while, depending on the used positioning system. Check out the WRT Developer's Library for an example on calling the asynchronous version of the function.

You might want to install the simulation PSY to your device to remove the dependency to the availability of real positioning data.

Test application and other attachments (optional)

File:Exceptiontest.zip

Please rename the .zip file to .wgz before attempting to install it on the emulator or a real device.

This page was last modified on 1 August 2012, at 07:38.
154 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved