Monday, 11 February 2013

Working with Intents

        An Intent object encapsulates a task request used by the Android operating system.When the startActivity( ) method is called with the Intent parameter, the Android system matches the Intent action with the appropriate activity on the Android system. That activity is then launched.

The Android system handles all intent resolution. An intent can be very specific, including a request for a specific activity to be launched, or something vague, requseting that any activity matching certain criteria be launced. For the finer details on intent resolution, see the Android documentation.

Passing information with Intents

Intents can be used to pass data between activities. You can use an intent in this way by including additional data, called extras, within the intent.
To package extra pieces of data along with an intent, you use the putExtra( ) method with the appropriate type of object you want to include. The Android Programming convention for intent extra is to name each one with the package prefix.
for example, com.gaurang.androidcoders.NameOfExtra.

Using Intents to Launch Other Application

Initially, an application may only be launching activity classes defined within its own package. However, with the appropriate permissions, applications may also launch external activity classes in other applications.
There are well-defined intent actions for many common user tasks
for example, you can create intent actions to initiate applications such as the following :


  • Launching the built-in web browser and supplying a URL address.
  • Launching the web browser and supplying a search string.
  • Launching the built-in Dialer application and supplying a phone number.
  • Launching the built-in  Maps application and supplying a location.
  • Launching Google Sreet view and supplying a location.
  • Launching the built-in camera application in still or video mode.
  • Launching a ringtone picker.
  • Recording sound.
Applications may also create their own intent types and allows other applications to call them, which makes it possible to develop tightly integrated application suites.