Today, Let's explore the fundamental concept of the development of Android apps: The lifecycle of Activity. Understanding states by an Activity is essential to the development of apps robust and responsive. Let's look at the principal States of an Activity:
- Created: In this state, the Activity was created, but not are visible to the user. At this moment, happen the initialization of components and crucial variables.
- Started: When the Activity goes to state "Started", she becomes visible to the user, but she is not prepared to interact. At this moment that an Activity prepares to into the foreground.
- Resumed: The Activity is in the foreground and ready to interact. At this moment that apps normally waste more time. All interactions of users and visual updates happen at this moment.
- Paused: The Activity it's partially visible, but is not more in focus. This can happen when other Activities open above her or when a window of dialog is displayed.
- Stopped: The Activity is not more visible to the user. This can happen when another Activity fills the screen or when the user goes to another app. At the stopped state, the Activity is still in your state but can be finalized by the system if there is a lack of resources.
- Destroyed: The Activity was completely removed from memory or finished by the system. This can happen when the user closes the app or when the system needs to release resources. In this state, all the resources are released and the Activity is considered close.
Is important to understand these states to manage correctly the lifecycle of the Activity, ensure the resources use in an efficient way and the state is saved correctly to avoid lost information.
In the next article, we will talk about the management of the lifecycle of Activity and provide some tips and better practices to deal with the information between states.