What Is Life Cycle Inventory?

Life cycle refers to the life, death and death of an object. [1]

Life cycle

LCA research originated from the energy crisis in the 1960s. In the early 1970s, the research focused on packaging waste. For example, the Midwest Research Institute (MRI)
There are broad and narrow senses. Narrow meaning refers to the original meaning-life science term, that is, the organism from birth,
There are two main life-cycle approaches to life-cycle theory-one is the traditional, rather mechanical, view of market development (
Android application life cycle
The Android application consists of four components: Activity, Service, BroadCast Receiver, and Content Provider.
In most cases, each Android application will run in its own Linux process. When some code of this application needs to be executed, the process will be created and will keep running until the process is no longer needed, and the system needs to release the memory it occupied, and only stop when it is used by other applications.
An important and special feature of Android is that the life cycle of an application process is not directly controlled by the application itself, but is determined by the system according to some characteristics of the running application, including: Importance, the total available memory of the system.
For application developers, it is very important to understand the impact of different application components (especially Activity, Service, Intent Receiver) on the life cycle of the application process. If these components are not used correctly, the process will be destroyed when the application is doing important work.
A common mistake in the life cycle of a process is that when an Intent Receiver receives an Intent in its onReceiveIntent () method, it will return from this method. Once returned from this method, the system will consider that the Intent Receiver is no longer active, and it will also consider that its host process is not needed (unless there are other application components in the host process). As a result, the system destroys this process at any time, reclaims memory, and terminates any child threads that are still running. The solution to the problem is to start a Service in the Intent Receiver so that the system knows that there are active jobs in the process that are being performed.
In order to decide which process to destroy in the case of insufficient memory, Android will divide these processes into a "level of importance" according to the components running in these processes and the status of these components (as shown on the right).
Android application process level
1. The foreground process is a process that has an Activity (its onResume () method has been called) that is displayed at the forefront of the screen and interacts with the user. It may also be a running Intent Receiver (its onReceiveIntent () Method is running). In the system, there are very few such processes. Only when the memory is low enough to support the continuous operation of these processes, these processes will be destroyed. Usually, the device has reached the state that requires memory consolidation. The user interface does not stop responding, it can only destroy these processes;
2. The visible process has an Activity (its onPause () has been called) process that is visible to the user on the screen, but not displayed in the foreground. For example: a front-end Activity displayed in a dialog box is displayed on the screen, while the upper-level Activity behind it is still visible. Such a process is very important and is generally not destroyed unless it is destroyed in order to ensure the normal operation of all foreground processes. The Android process generally has a small number of visible processes. Only under special circumstances, the Android system will clear the visible processes to ensure the resources of the foreground process.
3. A service process is a process that has a Service that is started by the startService () method. Although these processes are not visible to the user, they usually do things that the user is concerned about (such as a network service where the background music player is playing music or background uploading and downloading data). Therefore, the system will destroy such processes only to ensure the normal operation of foreground and visible processes.
4. The background process is an Activity (onStop () method has been called) process that is not visible to the user. These processes do not directly affect the user experience. If these processes have completed their life cycle correctly, the system will destroy such processes at any time to release memory for the above three types of processes. There are usually many such processes running, so these processes will be stored in an LRU list to ensure that when the memory is insufficient, the last process seen by the user will be destroyed at the end.
5. Empty processes are those processes that do not have any active application components. The only reason to keep these processes is, as a cache, to shorten the startup time the next time the application component it belongs to needs. Similarly, in order to balance system resources between these cached empty processes and the underlying core cache, the system often destroys these empty processes.
When a process is to be classified, the system will choose the one with the highest importance level among all the active components in the process.
An Activity is usually a separate screen, and the Activity life cycle refers to the process from startup to destruction of the Activity. The Activity in the system is managed by an Activity stack. When a new Activity is started, it will be placed on the top of the stack and become the running Activity. The previous Activity remains in the stack and will not be placed in the foreground until the running Activity exits.
Activity appears in four states:
Active or Running: Also known as the running state, it is at the top of the Activity stack. It is at the top of the user interface and can be completely seen by the user and can interact with the user.
Pa Paused: The Activity loses focus and the Activity interface is partially blocked. The Activity is no longer at the top of the user interface and cannot interact with the user. A paused Activity remains active (maintains all states, member information, and keeps in touch with the window manager), but will be killed when the system memory is insufficient;
Stopped: The Activity cannot be seen by the user at all on the interface, which means that this Activity is completely blocked by other Activities, but it still retains all the status and member information, but it is no longer visible and its window is hidden ;
Killed: When the system memory needs to be used elsewhere, a stopped Activity is killed.
If an Activity is Paused or Stopped, it can be restored or deleted. A deleted (killed) Activity needs to be restarted if it needs to be restored.
The figure on the right shows the important state transitions of the Activity. The rectangular box indicates the callback interface of the Activity between state transitions. The colored oval indicates the state of the Activity.
Activity life cycle
In the picture on the right, Activity has three key loops:
The entire life cycle starts from onCreate () and ends onDestroy (). The activity sets all "global" states in onCreate () and releases all resources in onDestory (). For example: an Activity has a thread running in the background to download data from the network, then the Activity can create a thread in onCreate () and stop the thread in onDestory ().
The visible life cycle starts from onStart () and ends onStop (). During this time, you can see that the Activity is on the screen, although it may not be in the foreground and cannot interact with the user. Between these two interfaces, you need to keep the UI data and resources displayed to the user. For example, you can register an Intent Receiver in onStart to listen to changes in the data that cause the UI to change. ) Log out of it. OnStart (), onStop () can be called multiple times, because the Activity can switch between visible and hidden at any time.
The life cycle of the foreground starts from onResume () and ends onPause (). During this time, the activity is at the forefront of all activities and interacts with the user. Activity can often switch between resumed and paused states, for example: when the device is ready to sleep, when an Activity processing result is distributed, when a new Intent is distributed.
The entire life cycle of an activity is defined in the following interface methods, and all methods can be overloaded. All activities need to implement onCreate () to initialize settings. Most activities need to implement onPause () to submit changed data. Most current activities also need to implement onFreeze () interface in order to restore the settings set in onCreate (). status.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?