YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Get Values Out of The Container Quiz

Get Embed Code
4 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. Phew, now we've downloaded
    the container, we can go ahead and

  2. actually do something in
    our app that uses it.
  3. We can get things out and
    use them where we want.
  4. It's a simple matter of knowing
    the key and retrieving the value.
  5. First Get the ContainerHolder.
  6. Then retrieve the value by key.
  7. Obviously, you have to
    know the exact key.
  8. Here's how we get the daily
    special: we just call getString and
  9. pass the key daily-special.
  10. And that's all there is too it.
  11. Whenever the daily special updates, your
    app will automatically get the latest
  12. value without you having to
    make any changes to the code.
  13. Note, though, that the update only
    takes effect when the app is restarted,
  14. because the code to get the container
    is in the onCreate method.
  15. To try it out, update your app to
    show the latest daily special.
  16. In the ShowDailySpecial activity,
    define the method Update daily special
  17. that get's the daily special
    out of the container and
  18. updates the relevant text view so
    that your users can actually see it.
  19. And make sure that you actually
    call update daily special
  20. in the on create method.
  21. Run the app and show the daily special.
  22. And then In the Tag Manager dashboard,
    go ahead and change the daily special.
  23. Don't forget to publish your changes,
    and
  24. then restart your app and
    see if you get the new value.
  25. And hopefully the daily
    special will have changed.
  26. And go ahead and
    check all the boxes when you're done.