|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-1941FC6C-4E2B-5549-96C8-6090DB0C40E1" xml:lang="en"><title>Activity |
|
13 Manager Tutorial</title><abstract><p>This section explains how to implement Activity Manager. </p><p>An |
|
14 object of the <codeph>CUserActivityManager</codeph> class must be included |
|
15 as a member of the component which need to react to activity and inactivity.</p></abstract><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
16 <steps id="GUID-725EB747-9C99-5E57-A016-D10DC436BD2B"> |
|
17 <step id="GUID-F69BA9F9-AC38-5866-A67F-E652673B0580"><cmd/> |
|
18 <info>Create an object of <codeph>CUserActivityManager</codeph>. </info> |
|
19 </step> |
|
20 <step id="GUID-12BE60E0-5B72-5F55-933B-4447D704C8AA"><cmd/> |
|
21 <info>Create an activity callback function implementing the transition to |
|
22 device activity. </info> |
|
23 </step> |
|
24 <step id="GUID-A4D01DE0-8893-5B3D-BB77-7495CBA8149A"><cmd/> |
|
25 <info>Create an inactivity callback function implementing the transition to |
|
26 device inactivity. </info> |
|
27 </step> |
|
28 <step id="GUID-D88E0CAA-E804-5056-A2C6-13B763CCB3C5"><cmd/> |
|
29 <info>Call the <codeph>CUserActivityManager::StartL()</codeph> function using |
|
30 the object of <xref href="GUID-9159ADC6-DD8E-3DF7-A023-96E1ABCB14FC.dita"><apiname>CUserActivityManager</apiname></xref>. This function accepts |
|
31 the following three arguments: </info> |
|
32 <info><p><ul> |
|
33 <li><p>an integer representing the inactivity interval in seconds, </p></li> |
|
34 <li><p>the inactivity callback, and</p></li> |
|
35 <li><p>the activity callback.</p></li> |
|
36 </ul></p></info> |
|
37 <info>The callback arguments are instances of <xref href="GUID-6C5766BC-05DE-32A8-993D-6BB582931F43.dita"><apiname>TCallBack</apiname></xref>. </info> |
|
38 </step> |
|
39 </steps> |
|
40 <example><title>Activity manager example</title> <codeblock id="GUID-DBD2391D-F2DE-5905-9A8B-695C18699554" xml:space="preserve">#include <activitymanager.h> |
|
41 … |
|
42 // Activity Manager instance is created and started |
|
43 |
|
44 void CSomeComponent::ConstructL() |
|
45 { |
|
46 … |
|
47 iActivityManager = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
48 |
|
49 iActivityManager->StartL( iTimeout, |
|
50 TCallBack( HandleInactiveEvent, this ), |
|
51 TCallBack( HandleActiveEvent, this ) ); |
|
52 … |
|
53 } |
|
54 … |
|
55 // Handles inactive event |
|
56 TInt CSomeComponent::HandleInactivityEvent( TAny* aPtr ) |
|
57 { |
|
58 // Code to be executed in case of user inactivity |
|
59 … |
|
60 } |
|
61 |
|
62 // Handles active event |
|
63 TInt CSomeComponent::HandleActivityEvent( TAny* aPtr ) |
|
64 { |
|
65 // Code to be executed in case of user activity after an inactivity period. |
|
66 … |
|
67 } |
|
68 </codeblock> </example> |
|
69 </taskbody><related-links> |
|
70 <link href="GUID-7FCDBDFB-6548-52D2-A18D-608FC8F151A3.dita"><linktext>Activity |
|
71 Manager Overview</linktext></link> |
|
72 </related-links></task> |