Android Intent Example Code Description

Android Intent Example Code with Description

Here we will discuss about Android Intent with Example and Code Description. We will discuss using an Android Intent Example. There are two types of intents in Android. One is implicit intent and another is explicit intent. We will discuss both Android intents with proper examples here. If you are new to android intents, then you can refer my article Android Fundamentals and Components for more details.

In the same example we will use 2 buttons (buttons named as ‘Explicit Intent’ and ‘Implicit Intent’) in the main screen (Activity); so when we will click on the first button (Explicit Intent), we will start a new Android Activity using ‘Explicit Intent’. Similarly when we will click on the second button (Implicit Intent), we will start a web browser with a specified URL.


Android Intent Example Details

Below code snippet will start a new activity using an explicit intent with some extra data. Here you force explicitly to start a new activity called ‘SecondActivity.class’.

Below code snippet will start a new web browser with a specified URL using implicit intent. Here you request implicitly to Android OS for start a new web browser with a specified URL.

Note: We can use our intent in verities of ways. For example: Can send data from Android Services and Broadcast Receivers etc. We will discuss regarding the same in another example.

Create Project: Android Intent Example

1. Create a project with project name: IntentExample

2. Fill Application Name: IntentExample

3. Fill the Package Name as: techblogon.intentexample

4. I have used SDK version Android 4.0.3 and Eclipse Version Indigo. But you can use any version.

5. Add below 2 java files (MainActivity.Java and SecondActivity.Java) in you project’s /src folder.

  • MainActivity.Java

This activity is the base activity from which we will have 2 buttons and will use these for different Android Intents.

  •  SecondActivity.Java

This activity is the second activity, which we will start from the first activity using Android intent.

6. Add below 2 xml layout files (activity_main.xml and layout2.xml) in your project’s res/layout folder.

  • activity_main.xml

This is used in MainActivity.Java file for showing GUI on the first activity. Here we just added 2 buttons and one TextView for showing some information.

  •  activity_second.xml

This is used for showing GUI the second activity. Here we just used a TextView to display some information on the screen.

7. Add the below Manifest file (AndroidManifest.xml) in your project’s root folder.

  • AndroidManifest.xml

8. Build and Run the application, then observe the result.

Note: Also you can download the complete code and import the project as an Existing android project.

downloadDownload  Android Intent Example from Here.

I hope this tutorial can help you at it’s best.


Post By SmrutiRanjan (57 Posts)

Working @ Samsung as a Project Lead for Android Smartphones. I have been blogging since 2008. Previously I was writing articles for other bloggers, but finally I have started my own blog-"Techblogon".I am also an active contributor for the blog-"Gadgets n Gizmos World". Job is my necessity, but blogging is my passion.

Website: → Techblogon


4 Responses to Android Intent Example Code Description

  1. Robert says:

    Great instructions and downloadable source code really helps as i am learning Android Dev techniques. Thanks for taking the time…:)

  2. Chemietoilette says:

    I thіnκ that is one of the most ѕіgnificant infо
    for me. And i am satіsfied stuԁуing your artiсle.

    But should cοmmentary on some common issues, The
    web sіte taste іs pеrfесt, the
    artіcles is in realіty nice : D.

    Јust гight job, cheers

  3. thirupathi says:


    i want pass data from first Activity to third Activity how ????

    plz ……give some Examples

Leave a Reply

Your email address will not be published. Required fields are marked *

6 − one =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">