Android Intent


  • Android Intent is an asynchronous messaging element which can send data & action to various Activities / Background-Services / Broadcast Receivers.
  • While you are working on one activity, you can easily switch-over to another using Android Intent. In fact one of the most widely use of Android Intent is starting new Activities. Intent also acts as a carrier using which we can transfer data & communicate between different Activities / Background-Services / Broadcast Receivers.



Intent is classified in below 2 ways :

Android Intent type - Implicit / Explicit


  1. Implicit Intent  – This kind of Intent is used to invoke inbuilt system components or invoke components from another applications. (e.g. invoking Dialer key-pad using Implicit Intent)
  2. Explicit Intent – We can invoke new components(Activity / Service / Broadcast Receiver) of our own application using Explicit Intent. (e.g. Launching Dashboard Activity with Explicit Intent, when user clicks on submit button from Login Activity )



Explaining above code :

  • Line 1 We instantiate Intent class and pass two parameters to it based on type of intent. In case of Explicit Intent we pass context as 1st parameter & name of Activity / Service as 2nd parameter. In case of Implicit intent we pass Action as 1st parameter and parsed URI as 2nd.
  • Line 2 at this line we start the target component i.e. our new activity using startActivity(intent_instance) & we pass instance of Intent class which we created above. In case of services we need to use startService(intent_instance) & for Broadcast receivers we use sendBroadcast(intent_instance).
  • Line 3 finish()  method is mainly used to close the old component (activity / service / broadcast receiver). When we call finish() system revokes all resources of existing component and destroys it.  finish() method can also be used separately to destroy any component without using Intent. If we might need our older component then simply use Intent without using finish(), this will just pause it.



Let us understand Working of Android Intents with reference to – Application Stack (Memory stack where top activity is our running activity and rest all are paused activity). Here we have Currently running component – Activity1  &   Target component – Activity2


Case : 1      Launching Activity-2 after closing Activity-1 using finish()

Android Intent type - Implicit / Explicit

  •  Initially only Activity-1 is residing in Application stack and it is running since no other Activity is present on its top. Using Intent we start our target Activity-2 & close (destroy) our Activity-1 using finish() method. During this Activity-1 will be removed from App. stack and Activity-2 will be brought in front.


Case : 2      Launching Activity-2 without closing Activity-1 i.e. just Pausing Activity-1 or sending it in Background


Android Intent type - Implicit / Explicit


  • Initially only Activity-1 is residing in Application stack running in front. Using Intent we start our target Activity-2, but without closing (destroying) our Activity-1 we bring Activity-2 at its top. Over here Activity-1 will not be removed from App. stack since we have not called finish() and Activity-2 will be brought in front in running mode, pushing Activity-1 in Background.


So in this way we use Intent. More specifically you will study Intents in next Tutorial on Implicit Intent & Explicit Intent



Report Errors + Bugs & Become Insider for

We would like to hear you, if you find any error or misspelled phrase while reading our tutorials. By reporting mistakes through email to you could help other peers.