Saturday, August 22, 2009

A minimal Map application using MapActivity, with Android 1.5 SDK r3.

OS: Ubuntu 9.04
Java: Sun JDK 6
Eclipse version: 3.5 Galileo
Android SDK: Android 1.5 SDK r3

It's a very minimal Android Application to display MapView.

Actually, this exercise follow the tutorial, Hello, MapView, with more pictures to describe.

Create a Android Application HelloMapView.


Modify AndroidManifest.xml:
Add <uses-library android:name="com.google.android.maps" /> as a child of the <application> element.
Add <uses-permission android:name="android.permission.INTERNET" /> a child of the <manifest> element.


Modify main.xml to add a MapView.


You have to Obtaining a Maps API Key, and insert into the field "apikey"

Modify HelloMapView to extends HelloMapView from MapActivity, and also override isRouteDisplayed().


You can actually run this now, but all it does is allow you to pan around the map.


The project files can be downloaded here. Please note that you cannot run the application directly, you have to insert your own apikey, in order to make it work.

6 comments:

Mythios said...

I tried to launch the apps in both my Device and Emulator..
but the google MapView show a Blank white with grids...???
anybody know why?

Erik said...

Hello Mythios,

you need Obtaining a Maps API Key, for debug or Obtain a Maps API Key for Your Signing Certificate

Mythios said...

I generate adebug Map Key and it was working fine before, when i was attending a 5 day workshop.

But when i back to my office, i use the same key, I encounter this Blank Map problem.

I was told that debug Map Key should work fine in different PC.

any explanation for this?

Erik said...

hello Mythios,

As I know: different PC have different debug key, because the MD5 Fingerprint is not same.

That means, if you built your project in PC A using debug key, then you copy the project to another PC B, you have to re-generate the debug key using MD5 Fingerprint of PC B.

Mythios said...

Dear Er :

Thanks for the advise. It work for Debug apps

I got one more questions.
If I want to deploy my App with Map to market,
q1) can i use this debug key OR
do i need generate a separate LIVE key?

q2) If a separate LIVE key is require, is there any available tutorial here to show the steps?

Erik said...

Hello Mythios,

You need another key, pls refer Obtain a Maps API Key for Your Signing Certificate