Android Intents

In this tutorial you will learn about the Android Intents and its application with practical example.

It Facilitate communication between components, It is Used to invoke components. Uses of Intent are: Starting an Activity, Starting a Service ,Delivering a Broadcast etc.
Types of Intent : Explicit Intents, Implicit Intents .

Table Of Contents

Intent Objects

An intent objects is collection or bundle of information which used by Android System and also by the component which receives intent object. The following component are listed below which are contained by the intent object:
1.Action : Its an important of the Intent Objects and Action is a string that specifies the generic action to perform. The general action to be performed, such as ACTION_EDIT, ACTION_MAIN, ACTION_VIEW, ACTION_SEND etc.

2.Data : It is used to operate data, like person record in database ,It is expressed as a Uri.
Some of the example action/data pairs are listed below –

ACTION_VIEW content://contacts/people/1
Display information about the person whose identifier is “1”.

ACTION_DIAL content://contacts/people/1
Display the phone dialer with the person filled in.

ACTION_VIEW tel:123
Display the phone dialer with the given number filled in. Note how the VIEW action does what is considered the most reasonable thing for a particular URI.

ACTION_DIAL tel:123
Display the phone dialer with the given number filled in.

ACTION_EDIT content://contacts/people/1
Edit information about the person whose identifier is “1”.

ACTION_VIEW content://contacts/people/
Display a list of people, which the user can browse through.

3.Category: Its an optional part of Intent Objects which gives additional information about the action to execute.CATEGORY_LAUNCHER,CATEGORY_BROWSABLE are the common categories.

4.Extras : It transfer additional information in Key-value pairs from one class to another class. Using putExtra() methods and Bundle object we can transfer information.

5.Flags :Flags may instruct Android System to launch an activity. Its an optional part of Intent Objects.

Types of Intent

1.Implicit Intent :It can invoke any application from device which is able to perform action. In this case your app does not perform any action but others app does perform action.

For example you have content and you want to share that content so just create an intent with ACTION_SEND like below code:

2.Explicit Intent :Explicit intent is used to launch particular Activity or Service in App. In simple word Calling an activity from another activity is an Explicit Intent. We can also send data using putExtra() method using Explicit Intent. See below code :

* Calling an Activity from another activity :

* Passing Data using Intent :

* Getting Data from Intent :

 

In this tutorial we have learn about the Android Intents and its application with practical example. I hope you will like this tutorial.