<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ahad Bokhari &#187; &#187; Java</title>
	<atom:link href="http://blogspot.fluidnewmedia.com/category/programming/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogspot.fluidnewmedia.com</link>
	<description>Addy&#039;s Personal Blog..</description>
	<lastBuildDate>Thu, 02 Sep 2010 19:23:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Displaying Google Maps in the Android Emulator</title>
		<link>http://blogspot.fluidnewmedia.com/2009/04/displaying-google-maps-in-the-android-emulator/</link>
		<comments>http://blogspot.fluidnewmedia.com/2009/04/displaying-google-maps-in-the-android-emulator/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 16:01:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[*MVC]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobility]]></category>

		<guid isPermaLink="false">http://blogspot.fluidnewmedia.com/?p=1313</guid>
		<description><![CDATA[
This is a quick and dirty way to display Google Maps in Android.  Its really not that hard and after learning how to do this you can easily start thinking about how you want to architect your Android App using the different bundles that come with google (Maps are only one of them!!). 
Fire [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img src="http://blogspot.fluidnewmedia.com/wp-content/uploads/2009/04/emulator.jpg" alt="Google Emulator - Embed Web maps." title="Google Emulator - Embed Web maps." width="200" height="360" class="alignleft size-full wp-image-1314" /><br />
This is a quick and dirty way to display Google Maps in Android.  Its really not that hard and after learning how to do this you can easily start thinking about how you want to architect your Android App using the different bundles that come with google (Maps are only one of them!!). </p>
<p><strong>Fire up Eclipse / Create your Project</strong></p>
<p>Easily set up your own project here => I am using GANEYMEDE eclipse, which is the international version of the popular Eclipse IDE.  If you don&#8217;t have the <a href="http://developer.android.com/sdk/1.1_r1/index.html">Android SDK you can download it from here</a> and you can <a href="http://www.eclipse.org/downloads/">download Eclipse from here.</a>Also make sure you have the latest version of Java => <a href="http://www.java.com/en/download/index.jsp">download it from here.</a></p>
<p><span id="more-1313"></span></p>
<p>Your first step is to create the project within Eclipse (I will not get into how to install Android onto your computer) so refer to the screenshot.<br />
<img src="http://blogspot.fluidnewmedia.com/wp-content/uploads/2009/04/maps.jpg" alt="Create your Android Project" title="Create your Android Project" width="500" height="499" class="aligncenter size-full wp-image-1320" /></p>
<h3>GET YOUR MAPS API KEY</h3>
<p>With the Android SDK release v1.0, you need to apply for a free Google Maps API key before you can integrate Google Maps into your Android application. Please follow the simple steps below on how to obtain your key.  You may also refer to Googles detailed documentation here. You can also refer to <a href="http://code.google.com/android/toolbox/apis/mapkey.html">Google&#8217;s detailed documentation on the process here.</a></p>
<p>Since you are testing the application on the emulator locate the SDK debug certificate located in the default folder of <code>"C:\Documents and Settings\<username>\Local Settings\Application Data\Android"</code>. The filename of the debug keystore is debug.keystore. For deploying to a real Android device, substitute the debug.keystore file with your own keystore file. </p>
<p>To make things simple just add (debug.keystore) to a folder in C:\ (for example, create a folder called <code>"C:\Android"</code>).</p>
<p>Using the debug keystore, you need to extract its MD5 fingerprint using the <code>Keytool.exe</code> application included with your JDK installation. This fingerprint is needed to apply for the free Google Maps key. You can usually find the Keytool.exe from the <code>"C:\Program Files\Java\<JDK_version_number>\bin" folder.</code></p>
<p>Issue the following command to extract the MD5 fingerprint.</p>
<p><code>keytool.exe -list -alias androiddebugkey -keystore "C:\android\debug.keystore" -storepass android -keypass android<br />
</code></p>
<p><img src="http://blogspot.fluidnewmedia.com/wp-content/uploads/2009/04/cmd.jpg" alt="cmd" title="cmd" width="550" height="124" class="aligncenter size-full wp-image-1327" /></p>
<h3>Modify your android manifest.xml file</h3>
<p>The manifest file describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.</p>
<p><?xml version="1.0" encoding="utf-8"?></p>
<pre lang="JAVA">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="net.learn2develop.GoogleMaps"
      android:versionCode="1"
      android:versionName="1.0.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">

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

        <activity android:name=".MapsActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

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

</manifest>
</xml>
</pre>
<h3>Displaying your map</h3>
<p>Next to display the Google Maps in your Android application, modify the main.xml file located in the <code>res/layout folder</code>. You shall use the <code><com.google.android.maps.MapView></code> element to display the Google Maps in your activity. In addition, let&#8217;s use the <RelativeLayout> element to position the map within the activity:</p>
<pre lang="JAVA">
<?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:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
       android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ"

        />

</RelativeLayout>
</pre>
<p><strong>Make sure that you have applied your android api key</strong></p>
<h3>Modify the MapActivity class</h3>
<p>Lastly all you need to do is modify the MapActivity class in your #src folder. (Maps.Activity.java)</p>
<pre lang="JAVA">
package com.ahadbokhari.GoogleMaps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;

public class MapsActivity 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;
    }
}
</pre>
<p>The above steps are all you need to actually display the maps in your emulatore. Press F11 in Eclipse to deploy the application onto an Android emulator.   If you are experiencing problems then look over these three troubleshooting steps below:</p>
<p>Make sure that you add the package in your AndroidManifest.xml file.<br />
<uses-library android:name="com.google.android.maps" /><br />
Make sure you have internet permission (if you see nothing but grids in the emulator.) in the AndroidManifest.xml File.<br />
<uses-permission android:name="android.permission.INTERNET" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blogspot.fluidnewmedia.com/2009/04/displaying-google-maps-in-the-android-emulator/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
