You Are Here:

Community: Wiki

This page was last modified on 30 October 2008, at 14:24.

CS001162 - Launching an installed application

From Forum Nokia Wiki



ID CS001162 Creation date October 30, 2008
Platform S60 3rd Edition, FP2
S60 5th Edition
Tested on devices Nokia N96
Nokia 5800 XpressMusic
Category Web Runtime (WRT) Subcategory S60 Platform Services


Keywords (APIs, classes, methods, functions): device.getServiceObject(), Service.AppManager, widget.openApplication()

Overview

This code snippet demonstrates how to launch an installed application from a widget. The snippet describes two approaches:

  1. Using the AppManager Service API of the Web Runtime.
  2. 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.

See also

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
User Rating: qfnZuserE5FratingQNx5E2E0000X