NOTE: Of late, I have been getting requests for very trivial problems that many of you are facing in your day-to-day work. This blog is not to solve your "project" problems - surely not a "Support" site.
I just love to share my knowledge in my spare time and would appreciate any questions or feedback on the articles and code I have shared. I also do appreciate thought-provoking questions that would lead me to write more articles and share.
But please do not put your day-to-day trivial problems here. Even if you do, you most probably would not get a response here.

Search This Blog


Wednesday, 26 August 2009

Explicit Intent | Android Tutorial for Beginners (Part 2)

Having introduced you to the basic anatomy of an android application in the Part 1 of the series, I would like to show you an example where communication between 2 activities happens through an intent.

However, just one more detail to be introduced as promised and that is -
There are 2 types of intents that Android understands.
1. Explicit Intent
2. Implicit Intent

In an Explicit intent, you actually specify the activity that is required to respond to the intent. In other words, you explicitly designate the target component. This is typically used for application internal messages.

In an Implicit intent (the main power of the android design), you just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, you do not declare the target component and hence is typically used for activating components of other applications seamlessly
Note: Here for simplicity sake I tell an activity responds to an intent, it could as well be other types of components.
Now I will jump into the example which you can download from here:

This example has 2 activities:
1. InvokingActivity
2. InvokedActivity
The InvokingActivity has a button "Invoke Next Activity" which when clicked explicitly calls the "InvokedActivity" class.
The relevant part of the code is here:

        Button invokingButton = (Button)findViewById(;
        invokingButton.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
Intent explicitIntent = new Intent(InvokingActivity.this,InvokedActivity.class);

As explained in part 1 of the series, this is very much like an API call with compile time binding.
NOTE: The layout for InvokingActivity is defined in main.xml and for InvokedActivity in InvokedActivity.xml. The downloadable example can be opened in Eclipse Ganymede as an android project and can be executed.
In the next part of the series, we will see how to work with implicit intents which also needs us to understand intent-filters


  1. HI Sai Geetha,

    Doing Great Job...
    learning new things all the people to.
    sharing what we have learned do only some people like u......

  2. Very glad to have found your blog! I am pretty new to any kind of programming, and I was wondering if you would have any tips on using Eclipse for android development. For example what packages work best. Thanks again my friend!

  3. hello..
    do you know how to use alert dialog that when the user click ok button and then it will redirect the user to go another page?

  4. I have a doubt not regarding android , but regarding java?
    wat is the purpose of using JavaVirtualMachine(JVM) ?
    how it serves the purpose of platform independency in java?
    how it differs from other platform dependent languages like c/c++?
    Can u give elaborate and simple explanation for this doubt?
    -thanks in advance

    1. Hi,
      Java is a platform independent language developed mainly for Web browser developemnt.
      JVM is an interpreter. Unlike C/C++ Java is platoform independent.
      Which means, It must generate a binary that is understood by all the platforms. But, it is not possible. Here JVM comes into play. JVM, comes with Java run time environment, interprets the Bytecode developed while compiling Java Source Code.

      Hence, If you have any Java Byte code, it runs on all the platofrms that have JVM unlike C/C++ where a .exe generated on Windows platform cannot run on Linux platform.
      I guess you understood it..

    2. That's why JNI library is there to convert native code. Learn about JNI, you will understand better, how to use native code in java.

  5. hi sai,
    another doubt in corejava?
    wat is the purpose of using hashtable?
    why should vector() has its initial capacity set as 10?
    can u give me solution for these doubts?

    --thanks in advance

  6. Hai Sai Geetha,

    Hey i'm amazed by looking this blog,you are sharing worth one to all of us, thanks a lot.
    And one request i'm in need of some more code on services,please will u provide.?

  7. Hi Sai,

    It is really a great work and the way in which u r sharing the knowledge is stupendous.Please can you help me out from ApplicationA how to call an activity which resides in ApplicatioB
    using explicit intents.
    I tried harde but I was not able to do so,as I am very new to android and mobile apps as well.


  8. Hi Sai,

    It is really a great work and the way in which u r sharing the knowledge is stupendous.Please can you help me out from ApplicationA how to call an activity which resides in ApplicatioB
    using explicit intents.
    I tried harde but I was not able to do so,as I am very new to android and mobile apps as well.


  9. Hi Sai Geetha,
    Thanks for your valuable information on android. I have one doubt below i am posting my question, if possible can you give me the solution, you can mail the solution to "".

    My activity have two radio button in the middle of the screen, on the top of the two radio buttons, i need to scroll the different advertisements continuously from the right of the screen to the left. In what way i have to do, I kept the radio buttons, scrolling advertisements is left. Please help me to achieve this activity.

    Thanks in advance.

  10. Thank you so much! I'd been trying to figure out how to do this for a while.

  11. Hi Geetha, you are doing Very Great Job, AM suman Narayana Working for LG on Messaging domain, I would like to give you one Input we can extend this blog to the domain specific, from messaging domain I can contribute, and also we can explore much on framework level, please kindly reply your interest to

  12. Hi ,
    Am new to this Android SDK platform,so could you people help me out to solve my issue.
    so lets discuss brief about my issue, am developing small application in which am using sppiner to list all country states and zip codes so my question is when i select one country state in a list it should automatically populate and display its corresponding zip code.

    Awaiting for response

    Thanks in advance,

  13. Hi Geetha,

    I have some queries regarding android SDK.
    here are my problem statememts,

    1.How to place border around some fields in UI.
    2.How to call another activity from current activity e.g. making a phone call from current activity.
    3.How to use Pagination.

    and its very usefull if you provide any mail id so that i can mail you my queries directly becz i need to solve ASAP and till have lot many questions to get it solved

    thnaks in advance,

  14. Hi Sridhar,

    You can communicate between two applications through intents only of the called application declares in its manifest file that it can handle a call to a specific intent. Most often, this is done through implicit intents. You can however call it explicitly too. But the pre-requisite for that is called application should declare its intent or ability to respond to a call in its manifest file.

  15. Noble job!! Is it possible for u to mail the sample code as ppl cant open filesharinf sites in most of the workplaces :(

  16. hi ,

    on downloading sample codes, it leads to a mirror site. can you create another blog/page only for sample code which can be linked to this tutorial page. Because in workplace, we can't refer any mirror site for reference.

  17. Hi Sai,

    I building an application which step by step working is given below

    1.My Activity is start in which I create a server UDP Socket Which wait fot data from client side.

    2. Then i press to Home Button click browser Icon and start You Tube Video.

    3. My Background Activity finds data send by client and generate a dialog window Activity with "yes" and "No" Button

    4. After clicking on any Button the dialog window is disappear

    I have done the all above task.But my problem is

    1. when Dialog window appear the You Tube Video is Stop and never resume even after the Dialog window Activity and UDP Server Activity is pause.

    2. Can I start my first Activity(UDP SERVER SOCKET) as a service?

  18. Hello, I am familiar with other languages but new to Java. I don't understand what invoked the InvokingActivity at the start of the run.


  19. Hi this is sathish, i am very new to android development, I read your blog and examples.I appreciated it. I need some help.I have same scenario like below for a media player application, can you please refer this link,

    Can you give a solution ,

    thanks in advance

  20. Hi Sai,

    Could you pls suggest a method to store items in a list permanently using shared preferences and Map?

    Thanks in advance,

  21. Thank you for your effort! Your explanations are a very helpful starting point if one doesn't know a thing about androiding yet and aspires to get a basic understanding.

  22. Chandu..

    Hi Sai,
    How to get geopoint of my location,pls help me regards.

  23. Hi Sai Madam

    Am fersher,jst now i got job in UK based company as a tester now am in Bluetooth and Wifi domain.

    I was started writing Android application,this blog helpd me to learn lot of things on android.

    Thank you vry much ,hopn U will solve my doubts on application .

  24. Hi Sailatha,
    superb tutorials easy to understand.
    thanks for a lot

  25. Hello Madam

    I am Sai.I have a small query here,I recently started android programming and I am finding it very interesting.I have decided to create an application on my own which is called ElectricityBilling Application.

    I created 3 activities...
    1.ElecBillActivity(Screenshot: )
    2.AddBillActivity(Screenshot: )
    3.ResultActivity(Screenshot: )

    As you can see in the above screenshots...I successfully enterd into the 2nd activity by using the intents..but as soon as I click the Submit button in the 2nd activity,I am getting an exception.I tried many ways,but i am unable to understand the problem.I am also providing the link for my code (

    I am really interested to complete this as soon as possible,I request some very much appreciated assistence from you!


  26. Hi..
    Thanks for helping us..Really ROX.bukmarkd. :)

  27. Hi,
    Thanks for this good android tutorial.
    Extreme Java

  28. Nice blog. I will keep visiting this blog very often.
    Thanks , for much information,Keep sharing such a wonderful information..!

  29. Hello and thank you for this superb blog, this awesome tutorial! I am very fortunate to have found it.

  30. HI,
    Sai Geetha
    Myself Praveen. This is superb tutorial for beginners.. If u give some more examples of different programs it will be helpful.

  31. This is a request for help.

    I am just starting to develop apps for the Android platform and I am struggling with a major hurdle at this time. For my current app, I need to have a video in it. My app contains strings and still images. Now, after the text and images, I want to have a video (e.g.,one of my videos in YOUTUBE) that will play when the running app gets past this chunk of text and images.
    How can this task be accomplished successfully?
    I emphasize "successfully" because I tried everything I could find via Google but nothing works so far.

    Please reply with step-by-step instructions, if possible.

    Thank you.

  32. hi i am naresh.i am working as a android developer in small organisation.i am fresh Btech graduate.wili i get better oppertunities as a android developer after getting experience.will i get a job in MNC's.

  33. Hi, I am Tarun , from Bangladesh. I am working as a junior android developer a firm. I attached your given code, but code showing error in my pc.

  34. Hai sai how to use intent for multiple activity?can u explain?

  35. This is one of the useful post.Your blog is presenting very good and new Information.Your blog is presenting variety and good Information.I like this post.Good.Android app developers

  36. This comment has been removed by a blog administrator.

  37. Thank you very much for this great tutorial

  38. hi sai..
    thanks for ur information...

  39. Hi Sai,

    Really very good article, I am new to android, according to you how do you see job chances in android here in india.

  40. plagiarism?

  41. Yes,

    Thanks for bringing this to my notice. It looks like the alotaboutandroid is copying my posts exactly and putting it into his blog. A shame indeed.

    When we want to share our knowledge freely, people want to misuse it!!

  42. Hi Geetha, you are doing Very Great Job, Thanks , for much information,Keep sharing such a wonderful information..!

  43. Unfortunately, they are not the only ones:


    And much more:

    You should email them warning for infringing your copyrights. However, possibly you should put a copyright first :-) It is not so hard in fact, you can just put a link to Creative Commons or so (allowing to copy whatever they want, but giving you the credit for your original creation), and it would be clear they are doing something they shouldn't.

    My 2 cents.

  44. Hello madam this is chandra sekhar.
    can you please help me by providing the example of intents without entering the details dont allowing it togo to next activity.
    Please help me madam

  45. This is very helpful! Thank you very much for sharing your knowledge.

  46. Hi Geeta, Your tutorials appear to be very helpful but I tried running them with Android 4.0. I am new to Android development and just learning. I took the Implicit Intent and rewrote it instead of directly running your tutorial to get hands on and I think I have everything pulled from your source but when I start my android in debug mode, I do not get the button or anything like that. I get an android screen which does not show any buttons. What could I be doing wrong.

    I have very careful pulled all your code together and it all compiles.



  47. hi sai
    this is problem is when i am ready to execute the program always it displays error as is not resloved......plz send me the answer i am new to the android

  48. How can mobile app developers help your business? There are 'n' of Android development company are there in that Rize is a most rated company.

  49. hi Sai
    this is manasa...pls tell me in how many types to create tha database in android..everytime am using db.exex.SQL()..and in ur blog u just give syntaxes only..why should u go for the programs....

  50. Hi Sai,
    All the very best wishes ,I will love to read an article on "RIL".
    Can u post it on our blog .

    Thanks &Regards

  51. hi

    U are doing very good job.

  52. hi,

    could you please list the same examples for MAC OS X also ?

  53. Sai,

    your post are very organized way and easy understandable. Doing a good job.

    Thanks a lot for your time and sharing. Keep posting ...

  54. For the beginners this is really nice post.because this provides basic concept of android development.both the part are good for viewers.

  55. This comment has been removed by a blog administrator.

  56. This comment has been removed by a blog administrator.

  57. hai madam this vinoth kumar(Moorthy student) from chennai what is strict intent


  58. Geetha,

    Your blog is very useful for me, as your tutorial sessions are indeed of great benefit.