English subtitles

← Intents as Envelopes - Developing Android Apps

Get Embed Code
10 Languages

Showing Revision 16 created 05/24/2016 by Udacity Robot.

  1. I like to think of intents as envelopes,
    each one who includes who,
  2. or in this case, which component
    you want it delivered to.
  3. And there's room for a small amount
    of data to be delivered,
  4. packaged as extras.
  5. Primitive tuples that will be
    available to the application component
  6. that ultimately receives
    and opens this intent.
  7. An explicit intent explicitly specifies
    the name of the recipient,
  8. as you can see on this envelope.
  9. Implicit intents are a lot
    more interesting.
  10. Here, we don't specify
    the name of the class.
  11. We don't even know what it is.
  12. So, how do we indicate
    which activity to launch?
  13. You know those stories you
    sometimes hear about letters
  14. with fake addresses like these
    that somehow still find
  15. their way to the recipient?
  16. Well the intent resolution system
    on Android works the same way,
  17. finding an activity
    capable of performing the action
  18. you specify on the associated data.
  19. So, rather than specifying
    the name of a class, you indicate
  20. an action you'd like
    an activity to perform,
  21. and on what data that action
    should be performed.
  22. Like this, where we want
    to address an activity
  23. that's capable of viewing a website.
    And because intents can cross
  24. through application boundaries,
    the activity that started
  25. may not be part of your app.
    So, you can include functionality
  26. like this, browsing websites
    or making phone calls
  27. or choosing a contact
    from your address book,
  28. all from within your app,
    without you having to implement
  29. any of it yourself.
  30. You don't even need
    to know about the app
  31. that will ultimately service your request.
    You can find details
  32. of some of the intents
    supported by native apps
  33. in Common Intents page
    of the Android developer site.