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,








2 comments:

  1. Hi Manish,
    I want to know how to get a particular location in Google Map. For example- There is a text box where i can write address and i'll get route direction. Please do that and post. your site helps a lot for new android developers.

    Thank you.

    ReplyDelete
  2. how to get android device current direction or degree from GPS?

    ReplyDelete