Launching an installed application from Symbian Web Runtime
This code snippet demonstrates how to launch an installed application from Symbian Web Runtime.
Article Metadata
Tested with
Devices(s): Nokia N96
Nokia 5800 XpressMusic
Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP2
S60 5th Edition
S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.AppManager, widget.openApplication()
Created: tapla
(24 Oct 2008)
Last edited: hamishwillee
(04 Oct 2012)
Contents |
Overview
The snippet describes two approaches:
- Using the AppManager Service API of the Web Runtime.
- Using the openApplication method of the widget object.
The first approach is only available on devices that support S60 Platform Services. The second approach is available in every widget.
Note: For security reasons, the second approach cannot be used to launch a widget. This restriction does not apply for the first approach.
Source: widget.xhtml
<?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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="StyleSheet" href="style/general.css" type="text/css" />
<script type="text/javascript" src="script/script.js" />
<title>WRT Application</title>
</head>
<body>
<div id="bodyContent" class="bodyContent">
<!-- When the button is clicked, launch the application with the
UID of 0x100058F8 (the Profiles application) -->
<input type="button" value="Launch" onclick="launchApp('0x100058F8');" />
</div>
</body>
</html>
Source: script.js
var serviceObj = null;
window.onload = init;
// Initializes the widget
function init() {
// Obtain the AppManager service object
try {
serviceObj = device.getServiceObject("Service.AppManager", "IAppManager");
} catch (ex) {
alert("Service object cannot be found.");
return;
}
}
// Launches an application with the specified UID
function launchApp(uid) {
if (serviceObj != null) {
launchApp5thEd(uid);
} else {
launchApp3rdEd(uid);
}
}
// Launches an application with the specified UID by using the platform service
// object (only available on 5th Edition devices)
function launchApp5thEd(uid) {
var criteria = new Object();
criteria.ApplicationID = "s60uid://" + uid;
var result = serviceObj.IAppManager.LaunchApp(criteria);
if (result.ErrorCode != 0) {
alert(result.ErrorCode + ": " + result.ErrorMessage);
}
}
// Launches an application with the specified UID by using the WRT widget
// object (available in every WRT device)
function launchApp3rdEd(uid) {
// The openApplication method requires that UID is an integer, not a string
uid = parseInt(uid);
widget.openApplication(uid, "");
}
Postconditions
The application with the specified UID (0x100058F8, the Profiles application) is launched.


(no comments yet)