Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to use Camera in WRT Widget

From Wiki
Jump to: navigation, search

This article and code snippet below explains how to use Camera using Nokia Platform Services 2.0. Please note that camera support is not available in Platform Services 1.0

Article Metadata
Code Example
Installation file:
Tested with
Devices(s): Nokia N97 mini
Platform(s): S60
Keywords: Camera, startCamera
Created: vasant21 (12 Jan 2010)
Last edited: hamishwillee (14 Jun 2013)


There are two ways of including Platform Services 2.0 support in to the widget:

  • Installing platformservices_v2_0_beta.SIS, will add the JavaScript library to a common location (c:\system\widgetlibs\platformservices.js) that can be accessed by any widget.
  • Including the JavaScript library platformservices.js directly in a widget.

We will use the second option for simplicity and ease of testing the widget. In the code below we try to launch Camera and display the full path of the images which is taken while returning to the widget after talking few pictures.

Using Camera

<!-- includeing platformservices.js file -->
<script type="text/javascript" src="platformservices.js" charset= "utf-8" />
<script language="javascript">
var so = null;
// Lets first create camera object.
so ="", "", "");
alert("Error loading camera : " + e);
// Callback method to process the result, called when returned from the camera application.
function onCameraAppLoaded( transId, errorCode, result ){
if (errorCode == 0) {
// Lets display the full path of photos taken.
alert("Pictures taken : \n " + result.join("\n") );
// Callback method called on error.
function onCameraError( error ){
alert("Camera Error : " + error.message );
// Lets try to launch camera application.
var tid = so.startCamera(onCameraAppLoaded, onCameraError);

Sample Widget is a sample widget, install and launch, no dependencies

How to Test

  • Launch the widget first. It will start the Camera. You can take few pictures and exit from the camera application. This will bring you back to the widget displaying a dialog with the full path of the images recently taken from the camera.
This page was last modified on 14 June 2013, at 04:54.
46 page views in the last 30 days.