|
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="Defining the callback handler for an asynchronous method"/><meta name="DC.Relation" scheme="URI" content="GUID-E9A578AA-58C5-4902-B418-4CE44EA40D5D"/><meta name="DC.Relation" scheme="URI" content="GUID-1EFD7043-E9B8-4B4E-9EA6-A20B3EECC14A"/><meta name="DC.Relation" scheme="URI" content="GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608"/><title>Defining |
|
5 the callback handler for an asynchronous method </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-C7C3B541-8D28-4DC6-9003-ECF57F26C608">Defining |
|
8 the callback handler for an asynchronous method</h1><div> |
|
9 <p>The callback handler method is used with an asynchronous method call |
|
10 to retrieve the information requested by the call. The asynchronous call initiates |
|
11 the callback handler and then returns a <code>TransactionID</code>. |
|
12 This ID is used to map the asynchronous call to the correct callback handler |
|
13 instance and the result information it returns. You can call the result handler |
|
14 method from within the callback handler.</p> |
|
15 <p>Define a callback handler method for any <a href="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C.html#GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C">Service |
|
16 API</a> method that is called asynchronously. Use the following method |
|
17 signature:</p> |
|
18 |
|
19 |
|
20 |
|
21 <pre class="codeblock" id="GUID-A044965C-8E27-42AA-B7FE-F2F025955FB9">callback(transId, eventCode, result)</pre> |
|
22 <p>The system supplies the expected arguments:</p> |
|
23 <div class="tablenoborder"><a name="GUID-C0E6D8A6-2C30-4D8A-9572-5CF593A43C52"><!----></a><table cellpadding="4" cellspacing="0" summary="" id="GUID-C0E6D8A6-2C30-4D8A-9572-5CF593A43C52" frame="border" border="1" rules="all"><caption><strong>Table: </strong>Callback arguments</caption> |
|
24 |
|
25 <thead align="left"> |
|
26 <tr class="title "><th class="cellrowborder" valign="top" width="33.33333333333333%" id="d0e9121"> |
|
27 <p>Argument</p> |
|
28 </th><th class="cellrowborder" valign="top" width="33.33333333333333%" id="d0e9126"> |
|
29 <p>Description</p> |
|
30 </th><th class="cellrowborder" valign="top" width="33.33333333333333%" id="d0e9131"> |
|
31 <p>Value</p> |
|
32 </th></tr> |
|
33 </thead> |
|
34 <tbody> |
|
35 <tr class=""> |
|
36 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9121 "> |
|
37 <p><code>transId</code></p> |
|
38 </td> |
|
39 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9126 "> |
|
40 <p>This is a number representing the transaction that called the callback |
|
41 handler.</p> |
|
42 <p><code>TransactionID</code> was returned as part of the result |
|
43 of the initial asynchronous call.</p> |
|
44 </td> |
|
45 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9131 "> </td> |
|
46 </tr> |
|
47 |
|
48 <tr class="bg "> |
|
49 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9121 "> |
|
50 <p><code>eventCode</code></p> |
|
51 </td> |
|
52 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9126 "> |
|
53 <p>This is a number representing the callback return status.</p> |
|
54 </td> |
|
55 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9131 "> |
|
56 <p><strong>Value - Description:</strong></p> |
|
57 <p><code>2</code> - Event completed</p> |
|
58 <p><code>4</code> - Event error</p> |
|
59 <p><code>9</code> - Event in progress</p> |
|
60 </td> |
|
61 </tr> |
|
62 <tr class=""> |
|
63 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9121 "> |
|
64 <p><code>result</code></p> |
|
65 </td> |
|
66 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9126 "> |
|
67 <p>This is an object for holding the callback return value.</p> |
|
68 </td> |
|
69 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9131 "> |
|
70 <p>See the following table.</p> |
|
71 </td> |
|
72 </tr> |
|
73 </tbody> |
|
74 </table></div> |
|
75 <p>The callback handler returns an object that contains the requested information, |
|
76 an error code, and an error message:</p> |
|
77 <div class="tablenoborder"><a name="GUID-E43BC9EA-3EBE-4C7F-A57E-A1C33BB01CF4"><!----></a><table cellpadding="4" cellspacing="0" summary="" id="GUID-E43BC9EA-3EBE-4C7F-A57E-A1C33BB01CF4" frame="border" border="1" rules="all"><caption><strong>Table: </strong>Callback return |
|
78 value</caption> |
|
79 |
|
80 <thead align="left"> |
|
81 <tr class="title "><th class="cellrowborder" valign="top" width="33.33333333333333%" id="d0e9242"> |
|
82 <p>Property</p> |
|
83 </th><th class="cellrowborder" valign="top" width="33.33333333333333%" id="d0e9247"> |
|
84 <p>Description</p> |
|
85 </th><th class="cellrowborder" valign="top" width="33.33333333333333%" id="d0e9252"> |
|
86 <p>Value</p> |
|
87 </th></tr> |
|
88 </thead> |
|
89 <tbody> |
|
90 <tr class=""> |
|
91 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9242 "> |
|
92 <p><code>[result.ReturnValue]</code></p> |
|
93 </td> |
|
94 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9247 "> |
|
95 <p>This contains the information requested by the asynchronous call that |
|
96 initiated the callback handler.</p> |
|
97 <p>If an asynchronous call does not request any information to be returned, |
|
98 this property is not included in the callback return value. In this case, |
|
99 the callback handler only returns <code>ErrorCode</code> and <code>ErrorMessage</code>.</p> |
|
100 </td> |
|
101 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9252 "> |
|
102 <p>Depends on the <a href="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C.html#GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C">Service |
|
103 API</a> and the asynchronous method that was called. Not all calls return |
|
104 this property. See the appropriate method definition.</p> |
|
105 </td> |
|
106 </tr> |
|
107 <tr class="bg "> |
|
108 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9242 "> |
|
109 <p><code>result.ErrorCode</code></p> |
|
110 </td> |
|
111 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9247 "> |
|
112 <p>This is a number that specifies a predefined error code.</p> |
|
113 </td> |
|
114 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9252 "> |
|
115 <p>See <a href="GUID-0A215AF3-59F0-4158-842C-0D7B030E5EA4.html#GUID-0A215AF3-59F0-4158-842C-0D7B030E5EA4">Service API error codes</a>.</p> |
|
116 </td> |
|
117 </tr> |
|
118 <tr class=""> |
|
119 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9242 "> |
|
120 <p><code>result.ErrorMessage</code></p> |
|
121 </td> |
|
122 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9247 "> |
|
123 <p>This is a text string that describes the error.</p> |
|
124 </td> |
|
125 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="d0e9252 "> |
|
126 <p>Depends on the <a href="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C.html#GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C">Service |
|
127 API</a> and the asynchronous method that was called. See the appropriate |
|
128 method definition.</p> |
|
129 </td> |
|
130 </tr> |
|
131 </tbody> |
|
132 </table></div> |
|
133 <p/> |
|
134 |
|
135 |
|
136 |
|
137 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html> |