×
Namespaces

Variants
Actions
(Difference between revisions)

Listing installed applications in Symbian Web Runtime

From Nokia Developer Wiki
Jump to: navigation, search
tapla (Talk | contribs)
(New page: __NOTOC__ __NOEDITSECTION__ {{CodeSnippet |id=  |platform=S60 5th Edition |devices=Nokia 5800 XpressMusic |category=Web Runtime (WRT) |subcategory=  |creationdate=Oct 20, 2008 |...)
 
tapla (Talk | contribs)
Line 7: Line 7:
 
|devices=Nokia 5800 XpressMusic
 
|devices=Nokia 5800 XpressMusic
 
|category=Web Runtime (WRT)
 
|category=Web Runtime (WRT)
|subcategory= 
+
|subcategory=S60 Platform Services
 
|creationdate=Oct 20, 2008
 
|creationdate=Oct 20, 2008
 
|keywords=device.getServiceObject(), Service.AppManager
 
|keywords=device.getServiceObject(), Service.AppManager
Line 46: Line 46:
 
function init() {
 
function init() {
 
     // Obtain the AppManager service object
 
     // Obtain the AppManager service object
     serviceObj = device.getServiceObject("Service.AppManager", "IAppManager");
+
     try {
 +
        serviceObj = device.getServiceObject("Service.AppManager", "IAppManager");
 +
    } catch (ex) {
 +
        alert("Service object cannot be found.");
 +
        return;
 +
    }
 +
 
 
     // We are interested in applications, so let's define the criteria
 
     // We are interested in applications, so let's define the criteria
 
     // respectively
 
     // respectively
 
     criteria = new Object();
 
     criteria = new Object();
     criteria.Type = 'Application';
+
     criteria.Type = "Application";
  
 
     // Obtain the list of installed applications
 
     // Obtain the list of installed applications
Line 95: Line 101:
 
The example displays an alphabetically ordered list of installed applications and their UIDs on an HTML page.
 
The example displays an alphabetically ordered list of installed applications and their UIDs on an HTML page.
  
[[Category:Web Runtime (WRT)]]
+
[[Category:Web Runtime (WRT)]][[Category:S60 Platform Services]]

Revision as of 11:50, 29 October 2008


Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.AppManager
Created: (20 Oct 2008)
Last edited: tapla (29 Oct 2008)

Overview

This code snippet demonstrates how to use the AppManager Service API to discover the applications that are installed on the device.

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"/>
<script type="text/javascript" src="script.js" />
<title>WRT Application</title>
</head>
<body>
<div id="bodyContent" class="bodyContent">
</div>
</body>
</html>

Source: script.js

var serviceObj = null;
var criteria = 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;
}
 
// We are interested in applications, so let's define the criteria
// respectively
criteria = new Object();
criteria.Type = "Application";
 
// Obtain the list of installed applications
var result = serviceObj.IAppManager.GetList(criteria);
var appList = createAppList(result.ReturnValue);
appList.sort();
displayList(appList);
}
 
// Creates the list of installed applications
function createAppList(iterator) {
var list = new Array();
try {
iterator.reset();
var item;
while ((item = iterator.getNext()) != undefined) {
var txt = "";
txt += item.Caption + " (";
txt += item.Uid + ")";
list.push(txt);
}
} catch (ex) {
alert(ex);
}
return list;
}
 
// Displays a list on the screen
function displayList(list) {
var listElement = document.createElement("ol");
for (var i = 0; i < list.length; i++) {
var listItemElement = document.createElement("li");
var textElement = document.createTextNode(list[i]);
listItemElement.appendChild(textElement);
listElement.appendChild(listItemElement);
}
var bodyContentElement = document.getElementById("bodyContent");
bodyContentElement.appendChild(listElement);
}

Postconditions

The example displays an alphabetically ordered list of installed applications and their UIDs on an HTML page.

85 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×