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 android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
There are three ways we can work with location data:
Using the my location layer
Using the Android Location...