Showing posts with label map. Show all posts
Showing posts with label map. Show all posts

Wednesday, October 17, 2012

Google Map in Android | Map Integration in android | MD5 and Google map demo

Hello Friends,
    I am going to share code for Google map in android hope it will help you.Important step for Create a Google map view are given below-

1-Generate MD5 Certificate from Google. You can follow below given URL.
http://androidhub4you.blogspot.in/2012/10/md5-certificate-fingerprint-in-android.html

2-Change main.xml with given below code


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.google.android.maps.MapView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="0vBPD0kMD00ljs8D_SB3ceBjDWfF5VunFYvebfQ" />

</RelativeLayout>

3-Copy and paste below code in your GoogleMapActivity.java


package com.example.googlemapdemo;

import com.google.android.maps.MapActivity;
import android.os.Bundle;

public class GoogleMapActivity extends MapActivity
{  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
}

4-Make changes in manifest.xml file add permission for Internet and add uses Library.


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.googlemapdemo"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps" />
        <activity
            android:name=".GoogleMapActivity"
            android:label="@string/title_activity_google_map" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Output:



Thanks,








MD5 Certificate Fingerprint in Android


          MD5 Certificate genration is needed for implement google map in our apllication so first we need to genrate md5 certificate.
We can generate it in different opperating systems-

Step1-

Windows Vista: C:\Users\<user>\.android\debug.keystore

Windows XP: C:\Documents and Settings\<user>\.android\debug.keystore

OS X and Linux: ~/.android/debug.keystore

Open console/terminal on to the above location where debug.keystore file is present and execute

"keytool -list -keystore debug.keystore"

Output will be like (press simply enter when password is asked)
=====================================================================
root@ZSS0057:~/.android# keytool -list -keystore debug.keystore
Enter keystore password:
*****************  WARNING WARNING WARNING  *****************
* The integrity of the information stored in your keystore  *
* has NOT been verified!  In order to verify its integrity, *
* you must provide your keystore password.                  *
*****************  WARNING WARNING WARNING  *****************

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

androiddebugkey, 11 Sep, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5): 04:FB:63:04:D5:6B:12:92:9F:3E:20:9F:23:DD:B8:53

Step2-
copy MD5 Certificate fingerprint and paste it in below url-

https://developers.google.com/android/maps-api-signup

You will get Map Keys On successful signup. Put those in the MapView Element of your view.


Thanks,