Android resource management and activity Lifecycles

♠ Posted by ANDROID THIRST in , at 23:16
What is an Activity?
An activity is a single, focused thing that the user can do. Almost all activity interact with the user,
So the activity class takes care of creating a window for you in which you can place your UI.

Android Process State :-  Process host applications and applications are made up of components .
within Android system, the current state of the system is defined by the highest - ranking active component within the application that it hosts. A process can be in one of the following five states
at any given time :

Foreground Process:- These processes are assigned the highest level of priority.At any one times, there are unlikely to be more than one or two foreground process active and these are usually the last to be terminated by the system. It's an activity with which the user currently interacting.

Visible Process:- A process containing an activity that is visible to the user but is not the activity with which the user is interacting is classified as a “visible process”. This is typically the case when an activity in the process is visible to the user but another activity, such as a partial screen or dialog, is in the foreground.

Service Process:- Processes that contain a Service that has already been started and is currently executing.

Background Process:- A process that contains one or more activities that are not currently visible to the user, and does not host a Service that qualifies for Service Process status. Processes that fall into this category are at high risk of termination in the event that additional memory needs to be freed for higher priority processes.

Empty Process:-Empty processes no longer contain any active applications and are held in memory ready to serve as hosts for newly launched applications. This is somewhat analogous to keeping the doors open and the engine running on a bus in anticipation of passengers arriving.

Activity Stack:-For each application that is running on an Android device, the runtime system maintains an Activity Stack. When an application is launched, the first of the application’s activities to be started is placed onto the stack. When a second activity is started, it is placed on the top of the stack and the previous activity is pushed down. The activity at the top of the stack is referred to as the active (or running) activity. When the active activity exits, it is popped off the stack by the runtime and the activity located immediately beneath it in the stack becomes the currently active activity.

What is Activity Lifecycle?


The class Activity provides a number of well-defined methods that are called when an application is started, suspended , restarted and so on. An activity can be in one of a number of different states during the course   of it execution withing an application.

Active State:-The activity is at the top of the Activity Stack, is the foreground task visible on the device screen, has focus and is currently interacting with the user.

Paused State:-  The activity is visible to the user but does not currently have focus.

Stop State:- The activity is currently not visible to the user.

Killed:- The Activity has been terminated by the runtime system in order to free up memory and is no longer present on the Activity Stack.



0 comments:

Post a Comment