Fundamental Components of An Android Application

Hey, we are going to tell you about the fundamentals of an android app in this article. so if you are a student or a developer or anyone who needs to the basic of the android app or the starting points of an android application can read this article.

Components of an Application

Component means a part of a larger whole, components in Android are parts that make up an Android app, they are basic building blocks of an Android app. the system enters your app through these components for example when you get a notification about calendar app, you click on it and it takes you to a specific activity. Any android app that you paid is made up of four basic components or fundamental elements those are

  • Activities
  • Services
  • Broadcast receivers
  • Content providers

What is An Activity in Android Application

Activity is any component which you can interact with. any user interface that you interact with, for example if you log into your app you will see a login screen, if you want to sign out your page, where sign-on screen, a sign-up screen on your dashboard etc. so any user interface that you see on your lap it’s nothing but an activity.

What are Services in Android App

Services are anything which does not have an interface but they run in the background. so anything which does not have an interface but they should be done in the background for a long period of time is the services. for example, you have downloaded a  large image from a website. so you can download it into a service and you could not have any UI and it would be running in the background or you want to sync the contents of your app with the contents of the server, so that you would use a service which runs in the background and there are all the same thing operations.

What is a Broadcast Receiver

Broadcast receiver is a subscriber pattern wherein you subscribe for some event and when that event occurs you can notify them saying that event has occurred. you can perform some operations on it. an example would be, you want to start your app or do something when the phone has just been started so if you can register for that event and as soon as your phone is restarted you will get an even saying your phone as we started. you can the corresponding operations that you need to perform on that evening.

What is content providers

Content providers are basically an abstract layer which helps in sharing data between different apps. you can imagine a content provider as basically a database from which different apps can query data, with the required permissions. the primary goal of a content provider is to share data between different apps. an example for content providers would be a contact manager wherein different apps can use a contact manager to get all the contacts, their phone numbers, their data from it.

Alll of these four components, the three components namely activity, services, and broadcast receivers can be activated by an intent. the fourth which is the content provider cannot be activated by an intent.

An intent basically a messaging system in Android, which is used to pass messages between different components of the Android system.

Manifest file

You must declare all the app components in the manifest files so the system knows that those components actually exist. when you create a new project with an empty activity, Android studio automatically declares that activity in the manifest file. you can declare permissions such as accessing the internet minimum API level, hardware requirements such as accessing the camera app or the fingerprint scanner.

manifest file in android app

All of these components are declared under the application element to declare an activity we use activity element, to declare a service use service element, for broadcast receivers use receiver element and for content providers use provider element.

How to define a components in Android Application

how to define component in android application

In the manifest file, you can declare an activity like using the activity tag. it has an attribute per name which is nothing but the class of the activity that you want to declare.

The Lable is nothing but the spring which will be displayed in the activity. interpreters are basically telling the Android system what intent will this activity respond to.

To declare a receiver, you can use the receiver tag differently with the name of the class given in the hydrocodone name. you can add an intent filter saying that for what events will this receiver responds. For Example, whenever a Wi-Fi state of the device changes, this receiver will get the notification and it will execute.

To declare service, you just need to use the service tag and you can give a name service in the name attribute of the tag. you need to use a provider tag, define a provider and the same goes for the signal.

so these are the basics of an Android app I hope you liked it and remember to Like, comment and share it on social media websites.

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!