Android google map api v2 usage key

Source: Internet
Author: User
Tags android sdk manager

1. Install the Google Play services sdk first.

Android SDK Manager-> Extras-> Google Play * (starts with three libraries of Google Play) and then install

2. Create an Api key

Register a google account first .. For details, feel free to explore.

Log onto the https://code.google.com/apis/console/ in Services and set the Google Maps Android API v2 option to ON status

Create a new Android key in Simple API Access in Api Access.

Note that the full name of the package named android is com. example. listviewdemo.

The SHA1 key is the key in the *. keystore file.

1) create a keystore file. After running the command, enter the information as prompted. Remember the password.

Keytool-genkey-aliasAlias_name-KeystoreYour_keystore_name. Keystore

Alias_name: alias

2) view the key

Keytool-list-v-keystoreYour_keystore_name. Keystore

After you enter the password, the key is displayed. The password here is the password set when the keystore is created. The line starting with SHA1 is the key.

Note: the default password for. android/debug. keystore is android.

3. Import the projectGoogle-play-services_lib, note here, it is best to copy this project, and then import the copy, to prevent accidental modification.

    <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib

======== Above is the preparation work ======

======= The following operations are for projects that want to use google Map api v2 ======

4. Create a pairgoogle-play-services_libProject Reference

Project-> Properties-> Android-> Library-> Add, selectgoogle-play-services_libJust save it.

5. Reference Android-support-v4.jar

Check whether Project-> Properties-> Java Build Path-> Libraries has been included. If not, Add External Jars.

<android-sdk-folder>/extras/android/support/v4/Android-support-v4.jar

6. Edit AndroidManifest. xml

<? Xml version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = "com. your. package. name "android: versionCode =" 1 "android: versionName =" 1.0 "> <uses-sdk android: minSdkVersion =" 8 "android: targetSdkVersion =" 17 "/> <! -- Added part --> <permission android: name = "com. your. package. name. permission. MAPS_RECEIVE "android: protectionLevel =" signature "/> <uses-permission android: name =" com. your. package. name. permission. MAPS_RECEIVE "/> <uses-permission android: name =" android. permission. INTERNET "/> <uses-permission android: name =" android. permission. WRITE_EXTERNAL_STORAGE "/> <uses-permission android: name =" com. google. android. providers. gsf. permission. READ_GSERVICES "/> <uses-permission android: name =" android. permission. ACCESS_COARSE_LOCATION "/> <uses-permission android: name =" android. permission. ACCESS_FINE_LOCATION "/>
  
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<! -- End of the added part -->
 
<!-- Somthing else ......-->    <application        android:allowBackup="true"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/AppTheme" >
<! -- Added part -->
 <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_api_key" />
<! -- End of the added part -->
 <!-- Somthing else ......--> </application></manifest>
 
 
 

7. Edit layout xml and add the following code. Activiti using this layout inherits FragementActivity, not Activity.

 

 <fragment        android:id="@+id/map"        android:layout_width="match_parent"        android:layout_height="match_parent"        class="com.google.android.gms.maps.SupportMapFragment" />

8. The Code has been completed, but you need to configure the mobile phone for normal use.

1) install google play service.apk

2) install google play store.apk

3) install google map.apk

Indispensable.

---- To be continued (we need to solve how to integrate the above three apk files. After all, people cannot download three applications for one function )----

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.