|
1 |
|
2 <!DOCTYPE html |
|
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="mobileconcept"/><meta name="DC.Title" content="JavaScript Sensor Service API"/><meta name="DC.Relation" scheme="URI" content="GUID-AEB26A58-1DE2-46CB-81EC-6DB3A477B7A3"/><meta name="DC.Relation" scheme="URI" content="GUID-91579EE5-A608-401C-82B4-DCF1723EC7B5"/><meta name="DC.Relation" scheme="URI" content="GUID-7C69DDA4-16F1-4A8F-BDB2-4CB0015B4E81"/><meta name="DC.Relation" scheme="URI" content="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-B77C2006-879F-4AC6-B7BF-04B25B563A29"/><title>JavaScript Sensor |
|
5 Service API </title><script type="text/javascript"> |
|
6 function initPage() {} |
|
7 </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-B77C2006-879F-4AC6-B7BF-04B25B563A29"><span>JavaScript</span> Sensor |
|
8 Service API</h1><div> |
|
9 <p>The <a href="GUID-6FBE64B7-0949-4AAE-B835-52B276540A59.html#GUID-6FBE64B7-0949-4AAE-B835-52B276540A59">Sensor Service</a> API |
|
10 is supported since <a href="GUID-1A3ECAC1-3F09-4602-A1CD-82164040A664.html#GUID-1A3ECAC1-3F09-4602-A1CD-82164040A664">WRT 1.1</a>.</p> |
|
11 <p>The Sensor Service API allows <span>widgets</span> to |
|
12 access data provided by the physical sensors of a device. The data from a |
|
13 given sensor is mapped to one or more sensor channels, which the API can listen |
|
14 to. The available sensors depend on the device. The API is integrated into <span>WRT</span> through |
|
15 the <a href="GUID-571AF37F-1E95-462A-92D2-FEA2E62F1559.html#GUID-571AF37F-1E95-462A-92D2-FEA2E62F1559"><code>device</code></a> object.</p> |
|
16 <p>For an overview of the service and the API, see section <a href="GUID-6FBE64B7-0949-4AAE-B835-52B276540A59.html#GUID-6FBE64B7-0949-4AAE-B835-52B276540A59">Accessing data from the physical sensors of a device</a>.</p> |
|
17 <div><h3>Using the Sensor Service API</h3> |
|
18 <p>To use the Sensor Service API, your <span>widget</span> must |
|
19 first create <span>a service object for it |
|
20 using the <a href="GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080.html#GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080"><code>device.getServiceObject()</code></a> method</span>. |
|
21 Use <code>Service.Sensor</code> to identify the service provider and <code>ISensor</code> to |
|
22 identify the supported interface:</p> |
|
23 |
|
24 <pre class="codeblock" id="GUID-9F7EE91E-7245-44A9-BFAE-BF043CA4E67D-GENIDd0e64468">var so = device.getServiceObject("Service.Sensor", "ISensor");</pre> |
|
25 <p>This service object can then be used to access the services provided |
|
26 by the API:</p> |
|
27 <ul> |
|
28 <li><p><a href="GUID-46DB749E-A388-46B2-BB13-A274385CA97C.html#GUID-46DB749E-A388-46B2-BB13-A274385CA97C"><code>ISensor.FindSensorChannel()</code></a></p> |
|
29 </li> |
|
30 <li><p><a href="GUID-B4897257-F7BC-4C32-9C6C-A577FDAC5D09.html#GUID-B4897257-F7BC-4C32-9C6C-A577FDAC5D09"><code>ISensor.RegisterForNotification()</code></a></p></li> |
|
31 <li><p><a href="GUID-3A306F4B-638D-4133-8575-2E269E565B7F.html#GUID-3A306F4B-638D-4133-8575-2E269E565B7F"><code>ISensor.Cancel()</code></a></p> |
|
32 </li> |
|
33 <li><p><a href="GUID-C2731B38-6294-419C-B7E2-AFB918F508D4.html#GUID-C2731B38-6294-419C-B7E2-AFB918F508D4"><code>ISensor.GetChannelProperty()</code></a></p> |
|
34 </li> |
|
35 </ul> |
|
36 </div> |
|
37 <div><h3>Emulator support</h3> |
|
38 <p>The S60 5th Edition SDK emulator support XML based-simulation for a |
|
39 few sensors.</p> |
|
40 </div> |
|
41 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html> |