Introduction

An Intent is a messaging object to request an action from another application component. Basically Intents are used to maintain or set up communication between two activities and certain broadcast receivers for performing an action given by the user.

How Intents can be used?

Intent Types

Explicit intents

These types of intents specify the component to start by name, in other words, the fully qualified class name must be called. We can use an explicit intent to start a component in our application. This can be understood as the fact that we are the developer of our own application and we already know the name of the activity and the service we want to start. For example, start a new activity in response to a user action or start a service to download a file in the background.

Implicit intents

Implicit intents do not specify the name of the component but instead declare a general action to do that allows a component from another application to handle it. For example, if we want to show a specific location to the user then we can use an implicit type intent to request that another capable application would show a specified location on a map.
intent diagram
Figure: creation and start with the processing of an Intent and Receiving another Activity, B (child activity)
Using this image one thing reflects implicit intents better by these arrows. When we create an implicit intent the Android system finds the appropriate component to start by comparing the contents of the intent to the intent filters declared in the manifest file of other applications on a device.
Here we can see that there is an Activity A (MainActivity.java) and Activity B (ChilldActivity.java) and in the middle, there is an Android System I have made, in other words, all the processing is done here.
A simple Intent is defined in the MainActivity.java file in which a startActivity() method is also defined that is taking an intent object as a signature. This line of code is just to set an intent and action is initiated.
Now intent goes for processing as shown in the figure and from there, an intent seeks another activity file. For receiving this intent another activity file must be there and in the onCreate() method of the second activity, we must define any receiver to get that intent.
Creating a Simple Intent in Activity A (MainActivity.java)
After seeing in the figure let us do it programmatically which classes we use and how many variables we will use:
onstart
However, this illustrates that an Intent is created and startActivity(intent) method is called so as to start an activity having an intent as a signature that is quite helpful and is implicitly created and seeks another activity to do some action.

Receiving an Intent

In the onCreate() method of the second activity below is the small code snapshot. Let us see and analyze it.
received activity
Now in this code, we can see how we are receiving the intent by calling the getIntent() method followed by the getStringExtra() method. This receiving is done in the onCreate() method of the child activity that is Activity B.

Summary

This article explains the basics and processing of intents and their function as well and how they are created explicitly and implicitly. However, the picture renders the good use and cycle of the intent from an activity to another activity.