Got a YouTube account?

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

English subtitles

← Describe Locatoin Workflow

Get Embed Code
4 Languages

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

  1. Building an app that uses Google
    Services generally follows this pattern.
  2. First, you'll create a Google API
    client, and on that client
  3. you'll specify the services that
    you want to use the desired API.
  4. In this case, it's location services.
  5. Now, the activity that hosts this
    client will need to be extended for
  6. the appropriate callbacks and listeners.
  7. The first of these is
  8. These allow you to code against
    events in the Api Client itself,
  9. such as connecting, or
    disconnecting from the services.
  10. The next is the
  11. GoogleApiClient.OnConnectionFailedListe-
  12. This can alert you when
    the connection drops,
  13. so that you can handle failures to
    connect to Google Apis Gracefully.
  14. Specifically for location services,
    you'll also need the location listener.
  15. And as its name suggests,
    it listens to location updates so
  16. that you can respond to
    them in your application.
  17. You then connect your clients and
    wait for the on connected call back.
  18. Now for this app, you're going to
    have code that makes a request for
  19. your current location.
  20. You put that in
    the OnConnected Callback, and
  21. this sets up another Callback
    called OnLocationChanged.
  22. And when the OnLocationChange Callback
    fires, it will contain your location
  23. information so that you can capture
    details such as the latitude, and
  24. update your UI accordingly.