Need help with directions? Or want to know your current location? Google Maps have got you covered! 

Google Maps is one of the great services that Google provides free of cost. This tutorial, you will create a simple application to display your current position in a map and update it every time as you move. Using Maps in your Android application is easy, simply follow the outlined steps below:

Step 1: Get Google Maps API key

To use the Google Maps Embed API, you must register your app project on the Google API Console and get a Google API key which you can add to your app or website. Go to the Google Maps API registration page and enter the MD5 certificate fingerprint to generate your API key.

Step 2: Create the Android Project

Create the Android project using the following settings:

To let your application use the Global Positioning System(GPS) of the Android phone, you need to add some permissions to the AndroidManifest.xml. These are the required permissions are for accessing location and internet services. After adding these permissions, your manifest file should like this:

<?xml version=”1.0″ encoding=”utf-8?>
<manifest xmlns:android=
android:versionName=”1.0″ >
android:targetSdkVersion=”10″ />
    <uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION” />
    <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” />
    <uses-permission android:name=”android.permission.INTERNET” />
android:theme=”@style/AppTheme” >
android:label=”@string/app_name” >
   <action android:name=”android.intent.action.MAIN” />
   <category android:name=”android.intent.category.LAUNCHER” />

Step 3: Create the View

In order to display the map in your Android app view add a MapView component inside your layout file.

<LinearLayout xmlns:android=
android:orientation=”vertical” >

android:apiKey=”Your key goes here
android:clickable=”true” />


Note: Replace the word "Your key goes here" with your API key.

Also, specify that you are going to use the Google Maps Library in the manifest. So add the following line to your manifest file:

<uses-library android:name=”” />

Step 4: Write the map activity

In order to use a MapView, extend the MapActivity. Create a simple Activity class extending the MapActivity as shown below:

package com.example.mymaps;
import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends MapActivity {
  private MapView map;
  private MapController controller;

protected void onCreate(Bundle savedInstanceState) {

   //functions to be implemented

public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu)
    return true;

protected boolean isRouteDisplayed() {
   // TODO Auto-generated method stub
   return false;

// Next thing that I did was to initialize my MapView:

private void initMapView() {
    map = (MapView) findViewById(;
    controller = map.getController();

// And lastly added my location overlay:

private void initMyLocation() {
   final MyLocationOverlay overlay = new MyLocationOverlay(this, map);
   //overlay.enableCompass(); // does not work in emulator

   overlay.runOnFirstFix(new Runnable() {
       public void run() {
        // Zoom in to current location

You are all set, now run your app in the simulator or on your phone. Is it telling your location correctly? If it does, you have correctly used the Maps API.

Some Guidelines:
•    Make sure that Google API is enabled for your Android Virtual Device (AVD).
•    You can set the GPS coordinates using the Dalvik Debug Monitor Server (DDMS) in Eclipse. Your app will NOT show anything until you set the coordinates.
•    Once you are sure your app is working fine don’t forget to sign it using a new certificate. The debug certificate is only for debugging!

 The complete Eclipse project is attached with the post.