Google Maps For Android

1.Create a new Project “Google Maps”.

2.To make map library part of the standard library ,Open the ‘AndroidManifest.xml’ file and put following code inside the <application> element,

<uses-library android:name="com.google.android.maps" />

3.To take permission from Internet to retrieve a Google Map,in the manifest file put the following code inside the <manifest> element,

<uses-permission android:name="android.permission.INTERNET" />

4.Open the ‘main.xml’ file from res/layout , add the Map View as root node,

<?xml version="1.0" encoding="utf-8"?/>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="Your Maps API Key goes here"/>

5.To generate Maps API key, first create your private key(my-private-key.keystore),go to the Terminal and type following command,

$ keytool -genkey -v -keystore my-private-key.keystore -alias alias_name -keyalg RSA -validity 10000

follow the procedure for each pinged questions and remember the alias and password.

6.Generate MD5 Fingerprint- After generating my-private-key.keystore generate Fingerprint by using following command,

$ keytool -list -alias alias_name -keystore my-private-key.keystore

this command will generate MD5 fingerprint for e.g. like this-
Certificate fingerprint(MD5):94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98

7.Take that MD5 fingerprint and go to the url=>http://code.google.com/android/maps-api-signup.html, you need to agree terms and conditions of android and paste your certificate’s MD5 fingerprint into the text-box and click on ‘Generate API Key’ Button.
your key will generate for e.g. like this-0M3kU2GKEeEbNi9kQxHJWKp3KLMDDfnEM5dv6uw

8.So use your Maps Api Key for project signing with your private key(my-private-key.keystore)-

<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0M3kU2GKEeEbNi9kQxHJWKp3KLMDDfnEM5dv6uw"/>

Continue reading

Advertisements