intents

Implicit and Explicit Intents in Android with Examples

What is intent in Android?

The intent is a messaging object which passes between components like services, content providers, activities, etc. Normally startActivity() method is used for invoking any activity. Some of the general functions of intent are:

1. Start service

2. Launch Activity

3. Display web page

4. Display contact list

5. Message broadcasting

Methods and their Description

Methods

Description

This is to launch a new activity or get an existing activity to be action.

This is to start a new service or deliver instructions for an existing service.

Context.startActivity()

Context.startService()

Context.sendBroadcast() This is to deliver the message to broadcast receivers.

Intent Classification:

There are two types of intents in android

1. Implicit Intent

2. Explicit Intent

Implicit Intent

Using implicit Intent, components can't be specified. An action to be performed is declared by implicit intent. Then android operating system will filter out components that will respond to the action. For Example,

Step by Step Implementation

Creating an Android App to Open a Webpage Using Implicit Intent

Step 1: Create a New Project in Android Studio

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. The code for that has been given in both Java and Kotlin Programming Language for Android, Create an XML file and Java File. Please refer to the pre-requisites to learn more about this step.

Step 2: Working with the XML Files

Comments

Popular posts from this blog