Android Intents – Basics

Introdution

So now you know, an Android application can contain zero or more activities. When your application has more than one activity, you often need to navigate from one to another. In Android, you navigate between activities through what is known as an Android Intent.

Android Intent is nothing but you can say its like a message to tell someone it is intent to do something. Where it can be used? Inside an android application it can be used for several expects,

  • Used to Broadcast and Transfer data between application and app components
  • Used to strat activities and services from application
  • Used to Broadcast the Events and Actions that some event has occured to notify other components of application

Intents are divided into two parts,

  • Explicit : used for delivering application internal messages (between the Activities)
    • Delivered to an instance of designated target class by using
      • startActivity(intent)
        • Starts new Activity (Data can be passed with intent)
        • Parent does not notify when child activity completes
      • startActivityForResult(intent, REQUEST_CODE)
        • same but parent get notify when child activity completes by OnActivityCompletes()
  • Implicit : used to activate components of other Android applications
    • Resolved by intent filters by object‟s (Action – Data – Category), so we have to specify related Action and Category to discriminate intents from each othre
    • System must find best component to handle intent, by looking for specific category and action so it can handle by specific application component very well

Another one is Intent Object, that is like it holds bundle of information within it in favor of the intent. Like it contains several information as below,

  • Component : an explicit name of component class to use for intent
  • Action : an action that to be perform
  • Data : the URI of data to be acted on which the intent will process
  • Category : a string that indicate kind of a component that should handle the intent
  • Type : which used to indicate Type of intent data
  • Extras : holds key-value pairs of information
  • Flags : used to instruct how to launch activity and how to treat it

If we look for the Actions, intent acquire lot many actions that can perform some intended tasks,
like

  • ACTION_MAIN
  • ACTION_VIEW
  • ACTION_DIAL
  • ACTION_EDIT
  • ACTION_PICK
  • ACTION_SEND_TO
  • ACTION_SEND . . . and lot more

Similarly if we take a look for categories, few of the categories are like:

  • CATEGORY_DEFAULT
  • CATEGORY_BROWSABLE
  • CATEGORY_TAB
  • CATEGORY_LAUNCHER
  • CATEGORY_INFO. . . and lot more

Get more in this video here. Click to Watch

So that’s it for all now about Android Intent. I think you people are now little bit aware about this concept. Stay connected for more articles related to Android Application Development.

 

“Bless for you, Peace for the World” – Purvik Rana

Leave a Reply

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