English subtitles

← Implementing the Receiver Class Quiz 2

Get Embed Code
4 Languages

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

  1. In the onReceive that you've just
    implemented, you got a context and
  2. an intent.
  3. Now remember earlier when you
    broadcasted the detected activities,
  4. you created an array list
    of detected activities and
  5. you put them into the intent.
  6. See now if you can create a new array
    list of detected activities and
  7. get them out of the intent.
  8. And here's a hint, you can use the get
    parcelable array list extra method.
  9. On the intent to do it.
  10. Check out the documentation for that.
  11. But that's the key.
  12. Now, once you've done this, you're going
    to easily iterate through this array
  13. list of detected activities, and you
    can get their type using the getType.
  14. Once you've done this you can iterate
    through the DetectedActivity objects in
  15. the ArrayList.
  16. Getting their type and the confidence
    for this type using the getType and
  17. getConfidence methods.
  18. Note that getType will actually
    return a code and not the string for
  19. the activity.
  20. You can find these codes on
    the DetectedActivity class.
  21. Go ahead now and write a helper function
    that turns this code into a string,
  22. and then implement
    this on your onReceive.
  23. When you're done, check this box.