Lets talk about the four fundamental building blocks from which all the android applications are built. These building blocks are implemented as Java classes.
Here is a diagrammatic representation of android application fundamental which explores android components and other fundamentals by Romain Chaippinelli.
Lets understand the four building blocks
Anything that is visible to the user has an activity. Basically, 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 runs in the background thread. We basically place long running operations in services. They provide a way for different processes to request operations and share data. eg: 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 listens to and responds to events. Broadcast receiver acts as a subscriber that listens to its required Intents and respond to it. eg: 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 Content Provider of that application. The access might be read or write or both operations. Similarly, content provider is used to provide data to the same containing application as well. Thus, we can say content provider is a database style component that handles interprocess communication between applications. eg: messaging app which can explore our contacts through contacts application.