Through my previous Articles, we have discussed developing a sample Android Application, “MyApp”; Build & Run the Application in Android Studio. In this article, I am going to explain, what are the core components of the Android application.
Lets’ take our already built Application “MyApp”; here is the Android view, which shows the list of components created in our Application.
Observe that, the Project has two primary groups; one is “
app” group and the other one is “
Gradle Scripts” group. “
Gradle Scripts” are the scripts to automate the build process. We can skip this now. We focus on “
app” group contains different sub-groups which contains different components; “
java” and “
res“. Why java? We use different languages to develop Android Applications. Our Project was developed using java, hence you are seeing “
java” sub-group inside “
app” group. We also can use C++ or Kotlin to develop Android Applications. Let me explain these in Android terminology.
Components are the building blocks of an Android application. Mostly the Android applications are built with the below components:
- App components
- Manifest file and
- App resources
Let me brief each of these components here. We will discuss more these in my upcoming Articles.
App components are the main building blocks of an Android application. We developed our Application in our previous Article, using Java language. Hence you see “
java” sub-group in the above picture. Under “
java” you see; “LoginActivity” & “MainActivity” components. These are the java classes created and we call these Activities; which is one of the App components.
Basically below are the App components:
An activity represents a user interface to allow the user to interact with the Application. From above, LoginActivity and MainActivity are the Activities defined to interact with the Application.
Have you ever used a stock ticker.? It displays continuously the latest stock prices; without interrupting the user interaction. This is happening, because there is a service running in the background; picking up the stock prices and giving them to Activities to display them. That means Services run in the background to keep the Android Application active and to do some activities in the background.
We can call these Broadcast Receivers, enable an Android Application to receive events or messages from the System or from other Applications.
Providers are used to providing something to its’ own Applications or other Applications. What is that? The something is the data. Primarily these are dealing with content or data; we call them Content Providers.
These are App components. Don’t worry; we will discuss them with examples; through relevant Articles.
Have you observed the “AndroidManifest.xml” file, in the above picture? This is the manifest file where Android Application components are declared. This is the file Android will look into first, before starting the Application; and based on the declarations in the manifest Android will run the Application.
These files are stored in the”
Other files related to the Application; like images, icons, styles, etc, should be part of Application resources. App resources will be used to change the look and feel of the Application.
App resources are stored in the”
These are the Core Components that constitute a complete Android Application.
We discuss more these components with working examples through my upcoming Articles.