Monday, 30 July 2012

Google map example in android

Android Google map and Google api key example
Hello Friends ,Here I am sharing the full tutorial of How to implements Google map
in your android application:

Step 1: Creating Key Store 


Open the command prompt and follow the steps

C:\Mukesh\Android-Sdk\tools>keytool -genkey -v -keystore projectkey.keystore -alias aliasname -keyalg RSA -keysize 2048 -validity 15000
Enter keystore password: ------------
What is your first and last name?
[Unknown]: ------------
What is the name of your 
organizational unit?
[Unknown]: ------------
What is the name of your organization?
[Unknown]: ------------
What is the name of your City or Locality?
[Unknown]: ------------
What is the name of your State or Province?
[Unknown]: ------------
What is the two-letter country code for this unit?
[Unknown]: ------------

Is CN=mukesh, OU=zss, O=zss, L=delhi, ST=delhi, C=dl correct?

[no]: yes

Generating 2,048 bit RSA key pair and self-signed certificate 

(SHA1withRSA) with a validity of 15,000 days

        for: CN=CN, OU=OU, O=O, L=L, ST=ST, C=C

Enter key password for <aliasname>

        (RETURN if same as keystore password): ------------

Re-enter new password: ------------

[Storing projectkey.keystore]
C:\Mukesh\Android-Sdk\tools>keytool -list -alias aliasname -keystore projectkey.keystore
Enter keystore password:
aliasname, Jul 22, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5):
A2:69:37:23:5B:27:68:B0:B7:5E:C1:61:08:04:F8:C0



Step 2: Obtaining Google API key for Google Map:
                                            Using Certificate fingerprint(MD5) you can get your get your google 
API Key from this link:
                         http://code.google.com/android/maps-api-signup.html 


Finally you get this:
Your key is: 
0NmasjBqpEvFTVP4IugZrbssdsIKnwPH2qSpd8g

This key is good for all apps signed with your certificate whose fingerprint is:

A2:69:37:23:5B:27:68:B0:B7:5E:C1:61:08:04:F8:C0

Here is an example xml layout to get you started on your way to mapping glory:
              <com.google.android.maps.MapView
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:apiKey="0NmasjBqpEvFTVP4IugZrbssdsIKnwPH2qSpd8g"
                 />


Use the above xml code and Enjoy...:)
Please Comment me or Ask if you face any problem.

Mukesh Yadav

Hi Guys I am from Delhi working as Web/Mobile Application Developer(Android Developer), also have knowledge of Roboelctric and Mockito ,android test driven development... Blogging has been my passion and I think blogging is one of the powerful medium to share knowledge and ideas....

0 comments:

Post a Comment

 

Copyright @ 2013 Android Developer Blog.

Blog Widget by LinkWithin