Working with Google's Location Services

In the previous chapter, we built our location-based alarm (LBA) app to include Google Maps, added a marker and customization of the location, and also built the UI for receiving user input for the alarm.

We will focus now on the integration of the Google Location API with our app and receiving updates on the user's location. The location of interest entered by the user will be saved and compared with the location updates received for the alarm to be triggered as the user reaches the area of interest.

Google provides various means to access and identify the location of the user. The Google Location APIs provides information on the user's last known location, display the location address, receive continuous updates on the location changes, and so on. Developers can add GeoFence—a fence around a geographical region—and any time users pass through the GeoFence an alert can be generated.

In this chapter, we will learn how to:

  • Use the Google Location API
  • Receive updates on the user's current location
  • Utilize user shared preferences to persist the user's location of interest
  • Match and display the alert when the user reaches the location of interest

The primary focus of this chapter is to introduce and explain the concept and usage of the location in our app. With this objective in mind, these concepts are explained with the app receiving the location updates when running in the foreground. The handling of required permissions is also handled in a simpler way.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset