|
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 concept |
|
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 |
|
13 |
|
14 const TUid KMyAppUid = {0x10009e9f}; |
|
15 |
|
16 // Creates an instance of a TApaTaskList taking reference to a window server session. |
|
17 // TApaTaskList allows access to all tasks running on the device. |
|
18 |
|
19 TApaTaskList taskList(CCoeEnv::Static()->WsSession()); |
|
20 |
|
21 // Creates a TApaTask instance that allows us to find out things about the task in question, for example: send a |
|
22 // key-stroke to it, abort or end the task. |
|
23 |
|
24 TApaTask task = taskList.FindApp(KMyAppUid); |
|
25 |
|
26 // Checks whether the specified task exists on the device. |
|
27 |
|
28 if (task.Exists()) |
|
29 { |
|
30 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"); |
|
32 TApaTaskList taskList(CCoeEnv::Static()->WsSession()); |
|
33 TApaTask task = taskList.FindApp(KAppName); |
|
34 if (task.Exists()) |
|
35 { |
|
36 task.BringToForeground(); |
|
37 }</codeblock> </section> </conbody></concept> |