这里的近期任务列表就是长按Home键出来的那个Dialog,里面放着近期打开过的应用,当然3.0以上系统的多任务切换键也是。
这个Dialog的实现在Android源码的.
接下来就对这个源码分析一下。
先把整个源码贴出来:
1public class RecentApplicationsDialog extends Dialog implements OnClickListener { 2// Elements for debugging support
3// private static final String LOG_TAG = "RecentApplicationsDialog";
4private static final boolean DBG_FORCE_EMPTY_LIST = false;
5
6static private StatusBarManager sStatusBar;
7
8private static final int NUM_BUTTONS = 8;
9private static final int MAX_RECENT_TASKS = NUM_BUTTONS * 2; // allow for some discards
10
11final TextView[] mIcons = new TextView[NUM_BUTTONS];
12 View mNoAppsText;
13 IntentFilter mBroadcastIntentFilter = new
IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
14
15class RecentTag {
16 ActivityManager.RecentTaskInfo info;
17 Intent intent;
18 }
19
20 Handler mHandler = new Handler();
21 Runnable mCleanup = new Runnable() {
22public void run() {
23// dump extra memory we're hanging on to
24for (TextView icon: mIcons) {
25 icon.setCompoundDrawables(null, null, null, null);
26 icon.setTag(null);
27 }
28 }
29 };
30
31public RecentApplicationsDialog(Context context) {
32super(context, com.android.internal.R.style.Theme_Dialog_RecentApplications);