歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android網絡-GoogleMap之GPS定位

Android網絡-GoogleMap之GPS定位

日期:2017/3/1 10:23:42   编辑:Linux編程

首先,獲取MapAPIKey

1,獲取Android keystore位置

eclipse->window->preferences->android->build

在default debug keystore下找到android key的存儲位置C:\Users\acer\.android\debug.keystore,備用。

2,用jdk提供的keytool為android keystore生成認證指紋

進入cmd,按下圖輸入

C:\Program Files\Java\jdk1.7.0_03\bin>keytool -list -alias androiddebugkey -keystore "C:\Users\acer\.android\debug.keystore" -v

密碼輸入:android或不輸。

取MD5值,備用


3,輸入網址http://code.google.com/intl/zh-CN/android/maps-api-signup.html

,登陸Google賬號,並且在申請頁面上輸入得到的MD5認證指紋,點擊”Generate API Key”來獲取我們得到的API Key

然後,創建基於Google APIs的AVD,以及創建基於Google APIs的工程

就是把所有Android2.2的都改為Google APIs

最後,編寫程序

程序效果:運行程序,send經緯度後,界面標記根據經緯度變化

manifest

注意添加internet和gps的權限,以及添加googlemap的library

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

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

  1. <strong><?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.song"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk android:minSdkVersion="8" />
  7. <application
  8. android:icon="@drawable/ic_launcher"
  9. android:label="@string/app_name" >
  10. <activity
  11. android:label="@string/app_name"
  12. android:name=".C7_GoogleMapActivity" >
  13. <intent-filter >
  14. <action android:name="android.intent.action.MAIN" />
  15. <category android:name="android.intent.category.LAUNCHER" />
  16. </intent-filter>
  17. </activity>
  18. <uses-library android:name="com.google.android.maps"/>
  19. </application>
  20. <uses-permission android:name="android.permission.INTERNET"/>
  21. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  22. </manifest></strong>
Copyright © Linux教程網 All Rights Reserved