An Android application with map

I had read a few tutorials on how to develop an Android appication with map display. Today I had actually built one. I would like to summarize the key points/steps in making this application work.

  1. First of all, get an Android Map API Key from Google.

This actually involves two steps. Firstly, you will have to create a key store to sign your Android application. This is quite easy and straightforward. Secondly, apply an Android Map Key from Google: http://code.google.com/intl/zh-CN/android/maps-api-signup.html. To make this work, you have to know where is your key store file is located (as created in the above step) and also have the JDK tool named keytool. From the command line, type:

   keytool -list -keystore the-path-to-your-key-store-file

It will prompt you to enter the password to the key store and will generate a MD5 finger print for this particular key store file. Copy this MD5 finger print to the above URI and Google will give you the Android Map API Key immediately. It is strongly suggested to save this Key information.

  1. Create an Android application.

Note: It must be created with target set to: Google APIs. You should not set the application target to Android x.x or it will not be running properly.

Note: The target of the AVD that runs the map application must also be set to Google APIs.

The coding of the application is actually quite simple. There are only two points to be highlighted:

  1. The application must be granted ACCESS_FINE_LOCATION and ACCESS_INTERNET permissions;
  2. The mapview controll used in the view must be provided with the API key generated in Step 1. It will look something like this:
<com.google.android.maps.mapview android:apikey="your" android:clickable="true" android:enabled="true" android:id="@+id/myMapView" android:layout_height="fill_parent" android:layout_width="fill_parent" api="" here="" key=""></com.google.android.maps.mapview>

With these settings, the map application can eventually run successfully.

However, in my implementation, the map shown in my AVD is only grids, no actuall maps at all. But in real machine (mine is Nexus One), the application is running correctly.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *