1. 建立你的應用程式,使用google api庫
2. 在你的布局RelativeLayout中引入一個MapView類
3. 擷取MD5認證指紋
用keytool產生認證(該工具在你的JDK bin目錄下):
keytool -genkey -alias agps -keyalg RSA -keystore mykey
說明:
這裡-alias agps是表示產生的這個認證的別名叫agps,-keyalg RSA 指的是採用的RSA演算法,-keystore mykey是指密鑰庫的位置,如果沒有該參數,則認證預設產生到使用者目錄(比如C:/Users/xf.chen/.keystore)。斷行符號後會提示你輸入keystore password,一些個人資訊及組織資訊。
用keytool -list查詢擷取到的MD5 fingerprint,比如:
C:/Program Files/Java/jre6/bin>keytool -list
輸入keystore密碼:
Keystore 類型: JKS
Keystore 提供者: SUN
您的 keystore 包含 1 輸入
agps, 2009-9-20, PrivateKeyEntry,
認證指紋 (MD5): 3B:21:23:50:8E:****
4. 擷取MAP API KEY
在如下網頁註冊擷取MAP API KEY: http://code.google.com/android/maps-api-signup.html(需要有google帳號)
5. 填寫到main.xml中:
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0hqzJey****"
/>