Well, I finally decided to start seriously looking at the Google API’s Add-On for Android projects. Specifically, the Google Map API’s. I was very curious by the fact that the Google Places API’s will be released next month (July, 2010) and am interested in Android apps that are able to locate and display places that are nearby, or in close proximity to your current location. FYI, more information on the Google Maps API Family is found here.
Of course, the easy thing was to find code snippets and information that quickly had me comfortable with using the Maps API. But then I needed to obtain a Maps API Key, and things slowed down a bit. So I decided to post a quick example and identify several links that will get you going faster than I got going.
Four important things to know are
- Signing your applications, preferrably with your own private key (however, an SDK debug alternative is available)
- Getting the MD5 fingerprint of your signing certificate (or SDK debug certificate)
- Signing up for the Android Maps API key (that is, generating the actual Maps API key)
- Update the android:apiKey located in your com.google.android.maps.MapView
Let’s look at a quick example.
In order to obtain a suitable private key, you must create a keystore that contains the one private key as follows:
C:\Users\homer\.android&amp;gt;keytool -genkey -v -keystore my-release-key.keystore -alias donut -keyalg RSA -keysize 2048 -validity 10000 Enter keystore password:evilbart Re-enter new password:evilbart What is your first and last name? [Unknown]: Homer Simpson What is the name of your organizational unit? [Unknown]: Huh What is the name of your organization? [Unknown]: Idunno What is the name of your City or Locality? [Unknown]: Springfield What is the name of your State or Province? [Unknown]: IL What is the two-letter country code for this unit? [Unknown]: US Is CN=Homer Simpson, OU=Huh, O=Idunno, L=Springfield, ST=IL, C=US correct? [no]: y Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days for: CN=Homer Simpson, OU=Huh, O=Idunno, L=Springfield, ST=IL, C=US Enter key password for &amp;lt;donut&amp;gt; (RETURN if same as keystore password): [Storing my-release-key.keystore] C:\Users\homer\.android&amp;gt;
To get the MD5 fingerprint, do the following:
C:\Users\homer\.android&amp;gt;keytool -list -alias donut -keystore my-release-key.ke ystore Enter keystore password:evilbart donut, Jun 6, 2010, PrivateKeyEntry, Certificate fingerprint (MD5): 44:F8:62:CB:3D:FC:23:44:C6:76:D3:26:47:0E:91:1B
Next, sign up for the Maps API key by supplying the fingerprint using the Android Maps API signup page
..resulting in the following:
And lastly, insert this key into your MapView like so
That’s it! Hope this helps.