intents n.
Skip this Video
Loading SlideShow in 5 Seconds..
Intents PowerPoint Presentation
Download Presentation

Loading in 2 Seconds...

play fullscreen
1 / 20

Intents - PowerPoint PPT Presentation

  • Uploaded on

Intents. Fancy pants definition of Intent. A passive data structure holding an abstract description of an operation to be performed or a description of something that has happened and is being announced. Regular pants definition.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Intents' - alissa

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
fancy pants definition of intent
Fancy pants definition of Intent

Apassive data structure holding an abstract description of an operation to be performed or a description of something that has happened and is being announced.

regular pants definition
Regular pants definition
  • Intents are asynchronous messages which allow Android components to request functionality from other components of the Android system.
  • Allows developers to leverage the capability of other apps
using intents
Using Intents
  • Intents are sent to the Android system via the startActivity().
  • Depending on how the Intent was constructed, the Android system will run an receiver and determine possible components that can be started.
  • If several components have registered for the same intents the user can decide which component should be started.
how we ve used intents so far
How we’ve used Intents so far
  • An Intent object is passed toContext.startActivity()or Activity.startActivityForResult() to launch an activity or get an existing activity to do something new.
  • It can also be passed to Activity.setResult() to return information to the activity that called startActivityForResult().
explicit vs implicit intents
Explicit vs Implicit Intents
  • Explicit intents explicitly define the component which should be called by the Android system by using the Java class as the identifier.
  • Implicit intents specify the action which should be performed and optional data which provides data for the action.
  • Intents can contain
    • Component Name
    • Action
    • Data
intents component name
Intents : Component Name
  • The name of the component that should handle the intent.
  • The name of the component should be a fully qualified class name of the target component its package name.

Package name

Fully Qualified Class Name

intents component name1
Intents : Component Name
  • Explicit Intents need a component name
  • Implicit Intents do NOT need a component name
intent action
Intent : Action
  • A string naming the action to be performed
intent data
Intent : Data
  • The data to operate on, such as a person record in the contacts database, expressed as a Uri.
examples of action data pairs
Examples of Action/Data pairs
  • ACTION_VIEWcontent://contacts/people/1 -- Display information about the person whose identifier is "1".
  • ACTION_DIALcontent://contacts/people/1 -- Display the phone dialer with the person filled in.
  • ACTION_VIEWtel:123 -- Display the phone dialer with the given number filled in. Note how the VIEW action does what is considered the most reasonable thing for a particular URI.
  • ACTION_DIALtel:123 -- Display the phone dialer with the given number filled in.
  • ACTION_EDITcontent://contacts/people/1 -- Edit information about the person whose identifier is "1".
  • ACTION_VIEW -- Display the browser with the given url filled in.
example intents long way
Example Intents : Long Way

Intent intent = new Intent();




example intents compact way
Example Intents : Compact Way

Intent intent = new Intent(Intent.ACTION_VIEW,



show phone number in dialer app
Show Phone Number in Dialer App

////Show Phone number in Dialer App

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:2147681234"));


google search
Google Search

////Open browser and perform a google search

Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);

intent.putExtra(SearchManager.QUERY, "SMU");


open address in google maps
Open Address in Google Maps

//Open Google Maps and load a map for a specific geo location

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:32.84453,-96.78534"));


compose an email
Compose an Email

//Compose an email with subject and body filled in

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:?subject=" +

Uri.encode("Mixed Berry Recipe") + "&body=" + Uri.encode("I found this awesome recipe")));


choose an activity to share data with
Choose an Activity to share data with

//Send data to any app that accepts text/plain mime type

Intent intent = new Intent(Intent.ACTION_SEND);


intent.putExtra(Intent.EXTRA_SUBJECT, "Subject Here");

intent.putExtra(Intent.EXTRA_TEXT, "Body Here");

//This will create a chooser pop-up that allows the user to select from a list of options for how they

//want to handle the intent (which app to use).

startActivity(Intent.createChooser(intent, "Share this recipe with")); //Add special text to chooser pop-up

edit contact
Edit Contact

//Edit a contact in your contacts list

Intent intent = new Intent(Intent.ACTION_EDIT, Uri.parse("content://contacts/people/1"));