In this post, we are going to discuss the four fundamental building blocks from which all the android applications are built. These building blocks are implemented as Java classes.
Pictured above is a diagrammatic representation of android application fundamental which explores android components and other fundamentals by Romain Chiappinelli.
There are four major building blocks of Android; let ’s understand them.
Anything visible to the user has an activity. Activity is the primary class which is defined to present the graphical user interface to the user and capture user’s interaction through that interface. An activity should support a single focused thing that the user can do. Eg: any UI visible in the app.
Unlike activities, services don’t require any user interface and run in the background thread. We place long-running operations in services. They provide a way for different processes to request operations and share data. e.g., music application, while we play a song, it is still playing in the background even though the app is closed.
Broadcast receivers are the fundamental components that listen to and responds to events. The broadcast receiver acts as a subscriber that listens to its required Intents and respond to it. Eg: a messaging app which shows a notification when a message is received.
If an application manages data and needs to expose that data to other applications, we use Content Providers. Content Providers allows applications to store and share data. If an application needs to access data from another application, this is done through the Content Provider of that application. The access might be read or write, or both operations.
Similarly, a content provider is used to provide data to the same containing application as well. Thus, we can say the content provider is a database-style component that handles interprocess communication between applications. Eg: messaging app which can explore our contacts through contacts application.
Originally Written by: Shilu Shrestha
Senior Mobile Developer @ Leapfrog Technology
Leapfrog Technology, Inc. is committed to helping clients design and develops high-performance mobile and web app that people love to use.