There are four different types of components in Android Application
- Broadcast Receivers
- Content Providers
Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped,
Each individual screen within an Android application is an activity, and users can perform actions by interacting with the visual components within an activity.
An application usually consists of multiple activities and each activity operates independently of one another
The visual objects within an activity (blocks of text, input boxes, buttons, etc.) are usually organized and instantiated by implementing instructions within a layout XML file.
Each activity in an Android application is either a direct subclass of the Activity base class or a subclass of an Activity subclass that provides specialized functionality (such as the ListActivity class which contains methods specifically for the display of data in a touch-enabled list), and is represented in the application package as a single Java class.
All Android application components, including activities, have lifecycles.All activities inherit a set of lifecycle methods from the Activity base class that are executed when the corresponding lifecycle state of the activity is reached.
These lifecycle methods are
- onCreate : This method is called when the activity is first instantiated/loaded into memory. This is the method in which you want to set up the intial state of your variables, instantiate the visual objects within the activity via your layout file, and bind your event listeners.
- onRestart: called when the activity is being restarted (made visible again) after executing onStop but not onDestroy.
- onResume: this method called just before the activity starts interacting with the user. After the onResume() method is called, the activity is considered to be "running."
- onPause: This method is called when the system is about to start resuming another activity.This method is followed either by onResume() if the activity returns back to the front, or by onStop() if it becomes invisible to the user.
- onStop: This method is called when the activity is no longer visible to the user. This method is followed either by onRestart() if the activity is coming back to interact with the user, or by onDestroy() .
- onDestroy: This method is called just before an activity is destroyed/unloaded from memory.
- onStart : This method is called just before the activity becomes visible to the user.