What is an Intent in Android? Types of Intent

In this lesson, you will learn what intent is? Before you understand what intent is, you first need to understand the activity. An end-user / non programmer can only interact with a page and called it a page, but an android programmer called it activity. So if you have an application that consists of one page ( Example Images), for android programmer calls it a “single activity” which consists of two files java file, and an XML file (i.e. MainActivity.java and activity_main.xml).
When you have an application that consists of four pages, in technical terms your application has four activities. Those four activities need some component to jump from one activity to another activity (to communicate between those activities).
To communicate one activity to another activity we use a component called “Intent”.
INTENT
The intent is a messaging object used to request an action from another component. In another way, an Intent facilitates communication between different components.
TYPES OF INTENT
There are two types of intent, namely;
- Explicit intent
- Implicit intent
Explicit Intent
An explicit intent is a type of intent that facilitate communication (jump from one activity to another activity) between two activities in the same application (inside the application). Example move from “LoginActivity” to “ProfileActivity”.
Implicit intent
Implicit intent is the type of intent that facilitate communication (jump from one activity to another activity) between two activities of different application. For example, when you want to move from a Facebook application to a web browser application, you can click a URL link from Facebook to the Browser application (like Google Chrome).
USES OF INTENT
- Intent used to start an Activity
- Intent used to start services (Open a web browser, email, and calling services)
- Pass data in the same application or different application
- Intent used to broadcast a message to all applications. For example when your mobile phone battery is low.