Listing installed applications in Symbian Web Runtime
hamishwillee
(Talk | contribs) m (Hamishwillee - Add Abstract. Tidy wiki text) |
|||
| (10 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | [[Category:Symbian Web Runtime]][[Category:S60 Platform Services]][[Category:Code Examples]][[Category:General Programming]] | |
| − | + | {{Abstract|This code snippet demonstrates how to use the AppManager Service API to discover the applications that are installed on the device.}} | |
| − | {{ | + | {{ArticleMetaData <!-- v1.2 --> |
| − | | | + | |sourcecode= [[Media:WRTStub CS001160.zip]] [[Media:CS001160 Listing installed applications.diff.zip]] |
| − | | | + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> |
| − | |devices=Nokia 5800 XpressMusic | + | |devices= Nokia 5800 XpressMusic |
| − | | | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> |
| − | | | + | |platform= S60 5th Edition and later |
| − | | | + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> |
| − | |keywords=device.getServiceObject(), Service.AppManager | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| + | |signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= device.getServiceObject(), Service.AppManager | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20081023 | ||
| + | |author= [[User:Tapla]] | ||
| + | <!-- The following are not in current metadata --> | ||
| + | |id= CS001160 | ||
}} | }} | ||
| − | |||
| − | |||
| − | |||
| − | |||
==Source: widget.xhtml== | ==Source: widget.xhtml== | ||
| Line 46: | Line 57: | ||
// Obtain the AppManager service object | // Obtain the AppManager service object | ||
try { | try { | ||
| − | serviceObj = device.getServiceObject("Service.AppManager", "IAppManager"); | + | serviceObj = device.getServiceObject("Service.AppManager", |
| + | "IAppManager"); | ||
} catch (ex) { | } catch (ex) { | ||
alert("Service object cannot be found."); | alert("Service object cannot be found."); | ||
| Line 100: | Line 112: | ||
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. | ||
| − | [[ | + | ==Supplementary material== |
| + | |||
| + | * You can test the application listing features in action in a simple, executable application into which this code snippet has been patched. The application is available for download at: [[Media:WRTStub CS001160.zip]] | ||
| + | * You can examine all the changes that are required to implement the above mentioned features in an application. The changes are provided in unified diff and color-coded diff formats: [[Media:CS001160 Listing installed applications.diff.zip]] | ||
| + | * For general information on applying the patch, see [[Using Diffs]]. | ||
| + | * For unpatched stub applications, see [[Example app stubs with logging framework]]. | ||
Latest revision as of 08:27, 4 October 2012
This code snippet demonstrates how to use the AppManager Service API to discover the applications that are installed on the device.
Article Metadata
Code Example
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition and later
Article
Keywords: device.getServiceObject(), Service.AppManager
Created: tapla
(23 Oct 2008)
Last edited: hamishwillee
(04 Oct 2012)
Contents |
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;
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
var 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.
Supplementary material
- You can test the application listing features in action in a simple, executable application into which this code snippet has been patched. The application is available for download at: Media:WRTStub CS001160.zip
- You can examine all the changes that are required to implement the above mentioned features in an application. The changes are provided in unified diff and color-coded diff formats: Media:CS001160 Listing installed applications.diff.zip
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example app stubs with logging framework.

