Intent And Intent Filter In Android - Day Eight

Introduction

 
In this article, we will learn how to share an application or anything with social networks, websites, etc. This article is very important if you want to share anything with anyone by using Intent and Intent Filter in Android. This is part eight of the article series. 
 
Before moving further, just read the following articles from day one to day seven,

What Is Intent?

 
The intent is basically the message which is passed between components like activities, content provider, etc. The intent is generally used to invoke the activity, broadcast receiver, etc.
 
Intents and its use-cases
  • To start an activity
  • To start a service
  • To deliver a broadcast
The primary information contained in an Intent is the following,
  • Component name
  • Action
  • Data
  • Category
  • Extras
  • Flags

Intent Types

 
IMPLICIT INTENTS
 
In this intent, it doesn’t specify the component, which means you can set the URL or any method which is invoked when you click on a button; the button method is called and implicit intent invoked.
 
IMPLEMENTATION
 
We declare the explicit intent on the button onclick method and set the URL it is mandatory that you give the initiative to start this intent.
 
intent
 
VISUAL REPRESENTATION
 
VISUAL REPRESENTATION
 
EXPLICIT INTENTS
 
Explicit intent basically specifies the component to be invoked from activity. In this type on intent we also pass the information from one activity to another activity.
 
code
 
In this method onclick event of the button we call the second activity by which is known as ArticlesActivity class.
 
COMMON INTENTS
 
Common intent is basically simple intent in which the specific components are displaed; you can select it and share the thing but the most important thing which you display is the list of components.
 
IMPLEMENTATION
 
IMPLEMENTATION
 
After declaring this message in the string section we move to the MainActivity class.
 
Now in main Activity we declare a method on onClick_share function,
 
code
 
VISUAL REPRESENTATION
 
 VISUAL REPRESENTATION
 
Read more articles on Android