|
||
Applications running on a device are known as tasks. The
TApaTaskList
class is used to access applications running
on a device, where each task has the potential to be an instance of the
TApaTask
class, which is used to manipulate or query
tasks.
This code example shows how to find (and end) a running application
(i.e. a task) by its UID using the TApaTaskList
and
TApaTask
classes.
const TUid KMyAppUid = {0x10009e9f};
TApaTaskList taskList(CCoeEnv::Static()->WsSession());
TApaTask task = taskList.FindApp(KMyAppUid);
if (task.Exists())
{
task.EndTask();
}
The following is a description of each line of the code example above:
Line 1: Assigns to a constant the UID of the application that we are trying to find.
Line 2: Creates an instance of a
TApaTaskList
taking a reference to a window server session.
TApaTaskList
allows access to all tasks running on the device.
Line 3: Creates a TApaTask
instance; this
allows us to find out things about the task in question, for example: send a
key-stroke to it, kill or end the task.
Line 4: Whether the specified task exists on the device
Line 6: Ends the task gracefully.
The following code example shows how to find an application by its name then bring it to the foreground.
_LIT(KAppName, "myApp");
TApaTaskList taskList(CCoeEnv::Static()->WsSession());
TApaTask task = taskList.FindApp(KAppName);
if (task.Exists())
{
task.BringToForeground();
}
It may also be worth looking at the following entries in the FAQ Knowledge base C++ FAQs:
FAQ-1129 What is an embeddable application?
FAQ-1169 How should I load a URI? How should my application
handle URIs?
FAQ-1241 How do CEikDialog-based dialogs 'block' when using
the EEikDialogFlagWait flag?