In this blog, we will discuss the Core Building blocks of Android. These building blocks are simply a piece of code that has a distinct life cycle.

Fundamental building blocks of Android are Activity, Intent, Views, Services, Content Providers, Fragments, and AndroidManifest.xml.

core building blocks of android

Let’s discuss a little bit more about these fundamental components of Android.

Activity

An activity is a single screen user interface. This the entry point of the users. Activity is the subclass of the ContextThemeWrapper class. An Activity starting with onCreate() callback method. An Activity has seven callback methods; those are used in different conditions.

Callback methods are:

  • onCreate(): it called when the activity is created.
  • onStart(): it called when the activity becomes visible of the users.
  • onResume(): it called when users interacting with the application.
  • onPause(): it called when the current activity is being paused and another activity is being resumed.
  • onStop(): it called when the activity is no longer visible for the users.
  • onDestroyed(): it called when activity is destroyed by the system.
  • onRestart(): it called when activity is a restart after stopping it.

And we should declare our activity inside the AndroidManifest.xml file or else it going to show run time error.

The declaration will be like:

Intent

It is used to invoke components, like

  • Start a new service
  • Display an another activity
  • Display a webpage
  • Display a message etc. Example:

Intent intent=new Intent(Intent.ACTION_VIEW);

intent.setData(Uri.parse(“https://www.gbandroidblogs.com"));

startActivity(intent);

The intent has two types:

  • Explicit Intent: Explicit Intent is used only for the internal purpose like to start another activity or send data between two activities. To start a new activity we have to create an Intent and set the source and destination activities. Example:
  • Implicit Intent: Implicit Intent is used to connect with the outer side of the application, like to make a call, sending mail, phone, see any web sites, etc. In implicit Intent we pass the action using setAction() function. Example:

for more visit GBAndroidBlogs

Thank you!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store