Prerequisites

The first important step before proceeding is to specify the required permissions to access GPS data. Two new permissions are required. They are:

  • android.permission.ACCESS_COARSE_LOCATION
  • android.permission.ACCESS_FINE_LOCATION

Let's discuss what these permissions are for:

ACCESS_COARSE_LOCATION

This permission is used to retrieve the approximate location from cell phone towers and Wi-Fi.

ACCESS_FINE_LOCATION

This permission is used to retrieve the accurate location from GPS satellites, cell phone towers, and Wi-Fi.

We have learned about permissions in Chapter 2, Configuring an API Key and Creating Our First Map Application. Similarly, we add the permissions to the AndroidManifest.xml file.

The permissions are added as follows:

<uses-permission ...

Get Learning Android Google Maps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.