The final way to get the GPS coordinates of your device’s location is through the map object. The map has built-in methods that access the sensors without writing any code to access the sensors. This makes things easier because all sensor management is handled by the map. The drawback is that you must display a map in the layout to use these features.
Return to activity_contact_maps.xml and delete all the widgets you put in the layout except the
navbar. Be sure to leave the root
RelativeLayout. Next, add the
MapFragment is not available in the Palette, so it must be added through XML. Refer to Listing 7.6 to do this.
<fragment android:id= ...