Join David Gassner for an in-depth discussion in this video Getting the current location programatically, part of Building Mobile Apps with Google Maps Android API v2.
I've shown previously how to create a user interface that lets…the user go to their current location using the My Location button.…But that doesn't give you programmatic control.…Next, I'll show you how to code to find…the current location, using something called the fused location API.…This is a recent introduction and is a part of the Google Maps Android API v2.…I'm working…in a version of the project called Current Location.…I'll run the application and show that this version of…the application has an action bar menu item called Current Location.…
Right now it doesn't do anything.…But the goal is to let the user go to the current location by touching that button.…The first thing I'll do is to get rid of the My Location button.…I'll go to the onCreate method…in the main activity and I'll…comment out the line of code, mMap.setmylocationEnabled(true).…And now, I'll start adding code that will…let me go to the current location programmatically.…There are a number of steps, first I'm going to change the signature…
Note: An Android device with Android 3.0 (Honeycomb) or higher, and that has Google Play Store installed, is required to use the course exercises. (Kindle Fire and Nook devices do not qualify.) Finished mapping apps can be deployed on Android 2.2 (Froyo) or later.
- Setting up the developer tools
- Adding required permissions
- Getting a Google Maps API key
- Importing and linking the Google Play services
- Setting a map's initial state
- Geocoding an address
- Getting the current location programmatically
- Adding map markers
- Handling marker events
- Drawing lines, polygons, and circles
- Adding maps to existing apps
Skill Level Intermediate
Q: In the Chapter 2 movie "Checking the device for the Google Play services APK," when I create my first Google Maps app, the app crashes when I call the custom method servicesOK(). The error in LogCat starts with: "java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value." How do I fix this?