From: http://wiki.forum.nokia.com/index.php/%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96%E6%AD%A3%E5%9C%A8%E8%BF%90%E8%A1%8C%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%88%97%E8%A1%A8
- Device, software version:
S60 1st edition s60 2nd edition and FP1, fp2, fp3 s60 3rd edition and FP1
Series 80 2nd Edition
Description
The application framework of the Symbian operating system provides a set of APIs to obtain information about the currently running tasks (whether running on the foreground or background ).
Solution
We can use tapatasklist to obtain the list of currently running tasks. The specific task is identified by the running program window group. when constructing the tapatasklist, we need to pass the session of the window server as a parameter.
#include <apgtask.h> // link against apgrfx.lib
TApaTaskList tasklist(CCoeEnv::Static()->WsSession());
TApaTask taskInForeground = tasklist.FindByPos( 0 );
// Window Group ID of the foreground task
TInt WindowGroupIdentifier = taskInForeground.WgId();
// Thread ID of the foreground task
TThreadId ThreadIdentifier = taskInForeground.ThreadId();
The first task in the tapatasklist is run on the foreground (the position sequence of the related window group starts from 0)
Tapatask includes many useful information related to tasks, such as threadid () and window group (wgid ()).
In addition, some useful functions, such as endtask (), are used to request the normal shutdown of a task, and killtask () is used to directly stop a task.
The sendtobackground () and bringtoforeground () methods can be used to control the position of a program in the task list.