android 任务列表标签,Android4.4 近期任务列表RecentsActivity与RecentTasksLoader

android4.4\frameworks\base\packages\SystemUI\src\com\android\systemui\recent\RecentsActivity.java

此函数是打开最近应用点击空闲地方跳转

public void dismissAndGoHome() {

if (mRecentsPanel != null) {

Intent homeIntent = new Intent(Intent.ACTION_MAIN, null);

homeIntent.addCategory(Intent.CATEGORY_HOME);

homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

startActivityAsUser(homeIntent, new UserHandle(UserHandle.USER_CURRENT));//这里是跳转到系统最高Launch 里面

}

}

//记录最近应用在这里面

android4.4\frameworks\base\packages\SystemUI\src\com\android\systemui\recent\RecentTasksLoader.java

protected Void doInBackground(Void... params) {

// We load in two stages: first, we update progress with just the first screenful

// of items. Then, we update with the rest of the items

final int origPri = Process.getThreadPriority(Process.myTid());

Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

final PackageManager pm = mContext.getPackageManager();

final ActivityManager am = (ActivityManager)

mContext.getSystemService(Context.ACTIVITY_SERVICE);

final List recentTasks =

am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);

int numTasks = recentTasks.size();

ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN)

.addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm, 0);

boolean firstScreenful = true;

ArrayList tasks = new ArrayList();

// skip the first task - assume it‘s either the home screen or the current activity.

final int first = 0;

for (int i = first, index = 0; i < numTasks && (index < MAX_TASKS); ++i) {

if (isCancelled()) {

break;

}

final ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(i);

Intent intent = new Intent(recentInfo.baseIntent);

if (recentInfo.origActivity != null) {

intent.setComponent(recentInfo.origActivity);

}

//关键代码

// Don‘t load the current home activity.

if (isCurrentHomeActivity(intent.getComponent(), homeInfo)) {//这里是屏蔽了系统最高launch 不记录在最近应用的栈中

continue;

}

// Don‘t load ourselves

if (intent.getComponent().getPackageName().equals(mContext.getPackageName())) {

continue;

}

TaskDescription item = createTaskDescription(recentInfo.id,

recentInfo.persistentId, recentInfo.baseIntent,

recentInfo.origActivity, recentInfo.description);

if (item != null) {

while (true) {

try {

tasksWaitingForThumbnails.put(item);

break;

} catch (InterruptedException e) {

}

}

tasks.add(item);

if (firstScreenful && tasks.size() == mNumTasksInFirstScreenful) {

publishProgress(tasks);

tasks = new ArrayList();

firstScreenful = false;

//break;

}

++index;

}

}

if (!isCancelled()) {

publishProgress(tasks);

if (firstScreenful) {

// always should publish two updates

publishProgress(new ArrayList());

}

}

while (true) {

try {

tasksWaitingForThumbnails.put(new TaskDescription());

break;

} catch (InterruptedException e) {

}

}

Process.setThreadPriority(origPri);

return null;

}

};

mTaskLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

loadThumbnailsAndIconsInBackground(tasksWaitingForThumbnails);

}

原文:http://blog.csdn.net/wang2470198567/article/details/39549141

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值