android最近的任务列表,对Android近期任务列表(Recent Applications)的简单分析

本文详细分析了Android系统中近期任务列表的实现原理,重点介绍了该列表对应的源代码,包括其核心类RecentApplicationsDialog的定义及其成员变量的功能,适合Android开发者深入理解系统机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

28352fc7b147a460994b62d768000bab.png

这里的近期任务列表就是长按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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值