Applications running on a device are known as tasks. The TApaTaskList class is used to access applications running on a device, where each task can be an instance of the TApaTask class, which is used to manipulate or query tasks.
The following example code shows how to find or end a running application that is, a task by its UID using the TApaTaskList and TApaTask classes.
// Assign UID of the application to a constant, to find the application by its UID const TUid KMyAppUid = {0x10009e9f}; // Creates an instance of a TApaTaskList taking reference to a window server session. // TApaTaskList allows access to all tasks running on the device. TApaTaskList taskList(CCoeEnv::Static()->WsSession()); // Creates a TApaTask instance that allows us to find out things about the task in question, for example: send a // key-stroke to it, abort or end the task. TApaTask task = taskList.FindApp(KMyAppUid); // Checks whether the specified task exists on the device. if (task.Exists()) { task.EndTask(); // Ends the task }
The following code example shows how to find an application by its name and then bring it to the foreground.
_LIT(KAppName, "myApp"); TApaTaskList taskList(CCoeEnv::Static()->WsSession()); TApaTask task = taskList.FindApp(KAppName); if (task.Exists()) { task.BringToForeground(); }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.