Got a YouTube account?

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

English subtitles

← Changing onConnected for Continuous Update

Get Embed Code
4 Languages

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

  1. Here's the solution.

  2. To create your mLocationRequest,
    you just simply call
  3. LocationRequest.create and
    then to set the high accuracy priority,
  4. you call LocationRequest.setPriority and
    pass it a constant
  5. PRIORITY_HIGH_ACCURACY which you'll
    find in the location request class.
  6. You've already set the interval to 1000
    milliseconds so then finally, all you
  7. have to do on the FusedLocationApi
    is requestLocationUpdates and
  8. pass it to GoogleApiClient,
    to LocationRequest, and this
  9. referring to this activity so that the
    call backs will come to this activity.
  10. All of these code should be on one line,
  11. I've just broken it up into separate
    lines here for easy reading.
  12. Now because you were
    requesting location updates,
  13. you'll need to implement a call back
    called on location changed which,
  14. as its name suggests, will get
    called whenever the location changes
  15. even just a little with this interval
    and this high accuracy determining that.