The life cycle of the Android process

Source: Internet
Author: User

In Android, there are five different processes: Activityprocess,visibleprocess,backgroundprocess,startedserviceprogress,backgroundprocess, Emptyprocess, these five states, their priority ranks from top to bottom:

First, the activeprocess of this process state is now in an active state, the user can interact with it, it can be said that the process is running, and can receive messages from the outside world.

Second, visibleprocess, this process is visible process, but at this time the process has lost the ability to interact with the user, that is to say, when there is a pop-up box on the current window sill, we can not normally click on the back of the form of the control, But we can clearly see the back of the form, this time the process is in this state.

Third, startserviceprocess this process is translated according to meaning is to open the service process, we all know the service process we can not see, but he is actually running, the state of this process is like this, Compared to the visibleprocess, he lost the interface again.

Iv. backgroundprocess This process is called the background process, he and startserviceprocess the difference is there is no service, for background this background process, there is no service, And startserviceprocess This process is a service, poor in here.

Five, the last emptyprocess, this becomes the empty process, the empty process is more sad, he not only has no service. It can be said that he left a virtual machine, for Android each program, this is standard, he left this layer, of course, he is waiting for someone to call again, so that he can recover at a very fast pace.

The following is the process of state transitions:

This is the pyramid-shaped life cycle:

The video also describes the situation when someone presses the home button or the return key after the process, the results show that two times the process has not been destroyed, even if it is called the finish function, there is still no destruction process, of course, according to the Android virtual machine garbage collection mechanism, if caught up with the current resource scarcity, it may be sacrificed this process, Because this process is currently the lowest priority and wants to completely destroy the process, there are two options:

One, system.exit (0);

Second, process.killprocess (PID);

This artificial shutdown and system resource scarcity the effect of the shutdown process is somewhat different: If the activity is destroyed by itself, the instance disappears forever, but if the system destroys the activity because of resource constraints, the instance is no longer present, but when the user returns to it, The system will recreate an instance using the data stored when the activity is destroyed.

This is what I see in other people's blogs, it is very important, and I also see:

The life cycle of the Android process

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.