7 Nokia Corporation - initial contribution. |
7 Nokia Corporation - initial contribution. |
8 Contributors: |
8 Contributors: |
9 --> |
9 --> |
10 <!DOCTYPE concept |
10 <!DOCTYPE concept |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
12 <concept xml:lang="en" id="GUID-0F1CB874-391F-5D44-B960-517E447DC712"><title>Accessing the Running Applications</title><shortdesc>Applications running on a device are known as tasks. The <apiname>TApaTaskList</apiname> class is used to access applications running on a device, where each task can be an instance of the <apiname>TApaTask</apiname> class, which is used to manipulate or query tasks. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody><section id="GUID-991C9C7B-42B7-5357-B09B-C8A0F59716B0"><title>Finding an application by its UID</title> <p>The following example code shows how to find or end a running application that is, a task by its UID using the <xref href="GUID-E1A1806C-8757-35DF-A4FB-AE3C63DED364.dita"><apiname>TApaTaskList</apiname></xref> and <xref href="GUID-851055CF-D5E6-34EA-8D4B-53FC50D90C24.dita"><apiname>TApaTask</apiname></xref> classes. </p> <codeblock id="GUID-C85440FD-57E3-5CB6-88A2-6F2551B37EF7" xml:space="preserve">// Assign UID of the application to a constant, to find the application by its UID |
12 <concept id="GUID-0F1CB874-391F-5D44-B960-517E447DC712" xml:lang="en"><title>Accessing |
|
13 the Running Applications</title><shortdesc>Applications running on a device are known as tasks. The <codeph>TApaTaskList</codeph> class |
|
14 is used to access applications running on a device, where each task can be |
|
15 an instance of the <codeph>TApaTask</codeph> class, which is used to manipulate |
|
16 or query tasks. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
17 <section id="GUID-991C9C7B-42B7-5357-B09B-C8A0F59716B0"><title>Finding an |
|
18 application by its UID</title> <p>The following example code shows how to |
|
19 find or end a running application that is, a task by its UID using the <xref href="GUID-E1A1806C-8757-35DF-A4FB-AE3C63DED364.dita"><apiname>TApaTaskList</apiname></xref> and <xref href="GUID-851055CF-D5E6-34EA-8D4B-53FC50D90C24.dita"><apiname>TApaTask</apiname></xref> classes. </p> <codeblock id="GUID-C85440FD-57E3-5CB6-88A2-6F2551B37EF7" xml:space="preserve">// Assign UID of the application to a constant, to find the application by its UID |
13 |
20 |
14 const TUid KMyAppUid = {0x10009e9f}; |
21 const TUid KMyAppUid = {0x10009e9f}; |
15 |
22 |
16 // Creates an instance of a TApaTaskList taking reference to a window server session. |
23 // Creates an instance of a TApaTaskList taking reference to a window server session. |
17 // TApaTaskList allows access to all tasks running on the device. |
24 // TApaTaskList allows access to all tasks running on the device. |
26 // Checks whether the specified task exists on the device. |
33 // Checks whether the specified task exists on the device. |
27 |
34 |
28 if (task.Exists()) |
35 if (task.Exists()) |
29 { |
36 { |
30 task.EndTask(); // Ends the task |
37 task.EndTask(); // Ends the task |
31 }</codeblock> </section> <section id="GUID-D785BAD1-5071-5766-89A7-26E925826B9F"><title>Bringing an application to the foreground</title> <p>The following code example shows how to find an application by its name and then bring it to the foreground. </p> <codeblock id="GUID-84318E73-F144-5031-853B-971E2257D0D5" xml:space="preserve">_LIT(KAppName, "myApp"); |
38 }</codeblock> </section> |
|
39 <section id="GUID-D785BAD1-5071-5766-89A7-26E925826B9F"><title>Bringing an |
|
40 application to the foreground</title> <p>The following code example shows |
|
41 how to find an application by its name and then bring it to the foreground. </p> <codeblock id="GUID-84318E73-F144-5031-853B-971E2257D0D5" xml:space="preserve">_LIT(KAppName, "myApp"); |
32 TApaTaskList taskList(CCoeEnv::Static()->WsSession()); |
42 TApaTaskList taskList(CCoeEnv::Static()->WsSession()); |
33 TApaTask task = taskList.FindApp(KAppName); |
43 TApaTask task = taskList.FindApp(KAppName); |
34 if (task.Exists()) |
44 if (task.Exists()) |
35 { |
45 { |
36 task.BringToForeground(); |
46 task.BringToForeground(); |
37 }</codeblock> </section> </conbody></concept> |
47 }</codeblock> </section> |
|
48 </conbody></concept> |