Day 9: Android Main Concepts: Intents


Over the next three days, we will explore some of the fundamentals of building an Android Application. They are –

  1. Intents
  2. Activities
  3. Services

Today, let’s explore what Intents in Android are –

Intents in Android are just data structures that are message objects. Intents can request an operation to be performed by some other component in Android. Intents are generally used to start Activities and Services in Android. We will explore in coming blog posts on how to use Intents to start an Activity and Services.

All Intents are classified into two Types –

  1. Explicit Intents
  2. Implicit Intents

Explicit Intents

Explicit Intents are where you specify Component that needs to be launched by its class name. The common use case for this is, when, you want to start an activity in your own Android App.

Let’s look at an example of Explicit Intent.

In our Simple Hello World Android Application, let’s add another Layout first –


Let’s also go ahead and add an Activity (You will learn what activities are in the next post, but for now please note that each screen in Android corresponds to an Activity. This Activity will work with the Details Layout that we just added –


Gist file link:

Now, let’s go back to our main Activity and write some code to make so that the button click on the activity takes us to newly created Details Activity.


Gist file link:

Notice in the button_Click method that we are constructing an Intent and then passing the details of the Activity we are hoping to move to (fully qualified name). And once an Intent is constructed, we just call “StartActivity” method with the intent as a parameter.


Main screen above, and once Navigate to Second Screen button is pressed then we move to Details Activity (Second Screen)


Implicit Intents

Implicit Intents don’t specify Component but rather define the action that needs to be performed. This actions are then handled by other apps in Android (be it be built-in or third party apps).

Some of the common examples for Implicit Intents are –

  1. Opening a Web Page
  2. Launching Maps
  3. Launching Phone Dialer

Let’s build a quick little sample that demonstrates all these


Opening a Web Page

To open a Web Page with Intents, you would use an Intent.ActionView action and pass URL message object. Let’s see it in action –


Launching Maps

To launch maps with Intents, you would use Intent.ActionView action and pass a Geo Location message object. Let’s see it in action –


Launching Phone Dialer

To launch phone dialer with Intents, you would use Intent.ActionDial action and pass a telephone number message object. Let’s see it in action –

Gist file link:


That’s it for today, tomorrow, let’s explore what Activities in Android are in more detail.


Get the CODE!
The following two tabs change content below.

Venkata Koppaka

Software Architect at Falafel Software
Venkata Koppaka has over 7 years experience developing variety of line of business applications to various financial and IT organizations. Venkata has been developing with all Telerik products since 2008, he ended working for Telerik on Sitefinity team as a senior developer for Ecommerce module. He is extremely interested in developing custom solutions for Sitefinity based Ecommerce stores. Venkata is a big fan of Test Driven Development and strives himself to write code that is completely testable and modular. Venkata has a Masters in Computer Science from Syracuse University, which drives his continuos learning addiction. In his spare time, Venkata develops apps for Windows Phone 8 platform and learns the most cutting edge technologies in software development. When he is not spending time on computer writing software, Venkata enjoys reading about cars and watching football.