Android4.4 Recent Task List recentsactivity and Recenttasksloader

Source: Internet
Author: User
Tags home screen

Android4.4\frameworks\base\packages\systemui\src\com\android\systemui\recent\recentsactivity.java

This function is to open the nearest app click Idle Place jump

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));//This is the jump to the system up to launch inside

}
}


Record recently applied in this face

Android4.4\frameworks\base\packages\systemui\src\com\android\systemui\recent\recenttasksloader.java


protected void Doinbackground (void ... params) {
We load in both Stages:first, we update progress with just the first screenful
of items. 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<activitymanager.recenttaskinfo> 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<taskdescription> tasks = new arraylist<taskdescription> ();


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);
}

Key code
Don ' t load the current home activity.
if (Iscurrenthomeactivity (Intent.getcomponent (), homeinfo)) {//Here is shielded the system highest launch not recorded in the most recently applied stack
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<taskdescription> ();
Firstscreenful = false;
Break
}
++index;
}
}


if (!iscancelled ()) {
Publishprogress (tasks);
if (firstscreenful) {
Always should publish and updates
Publishprogress (New arraylist<taskdescription> ());
}
}


while (true) {
try {
Taskswaitingforthumbnails.put (New Taskdescription ());
Break
} catch (Interruptedexception e) {
}
}


Process.setthreadpriority (ORIGPRI);
return null;
}
};
Mtaskloader.executeonexecutor (Asynctask.thread_pool_executor);
Loadthumbnailsandiconsinbackground (taskswaitingforthumbnails);
}

Android4.4 Recent Task List recentsactivity and Recenttasksloader

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.