I try to follow the documents to work with the Google Map API, but this is not work.
My manifest
& lt; Manifest xmlns: Android = "http://schemas.android.com/apk/res/android" package = "com.example.gogplemap" android: versionCode = "1" Android: version name = "1.0" & gt; & Lt; Use-sdk android: minSdkVersion = "8" Android: targetSdkVersion = "17" /> & Lt; Permission Android: name = "com.example.gogplemap.GOOGLEMAP" Android: protectionLevel = "signature" & gt; & Lt; / Permission & gt; & Lt; Usage-permission Android: name = "com.example.gogplemap.GoogleMap" /> & Lt; Android: Android: icon = "true_android": icon = & Lt; Activity Android: name = "com.example.gogplemap.GoogleMap" Android: label = "@ string / app_name" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.MAIN" /> & Lt; Category android: name = "android.intent.category.LAUNCHER" /> & Lt; / Intent-Filter & gt; & Lt; / Activity & gt; & Lt; Meta-Data Android: name = "com.google.android.gms.maps.MapFragment" Android: value = "AIzaSyBPQPMrlJk-Ft48z0CWvpWBRcLIRIJJ4X4" /> & Lt; / Application & gt; & Lt; / Reveal & gt; My layout activity_ google_map.xml
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Fragment xmlns: Android = "http://schemas.android.com/apk/res/android" Android: id = "@ + ID / map" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: name = "Com.google.android.gms.maps.MapFragment" /> View my method set in GoogleMap.java
Secure vs. creation (bundle saved instenstate) {super.onCreate (savedInstanceState); SetContentView (R.layout.activity_google_map); } Thanks a lot
Try this way: This will work for you!
Layout:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Piece xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: map = "http://schemas.android.com/apk/res-auto" Android: id = "@ + ID / map "Android: layout_width =" match_parent "Android: layout_height =" match_parent "class =" com.google.android.gms.maps.SupermarkMapFragment "/> Activity:
import android.os.bundle; Import android.support.v4.app.FragmentActivity; Import com.google.android.gms.maps.SupermarkMapFragment; Public class increases main activity fracture activity {@ Override Protected Zero to Crate (InstanceStatus saved from Bundle) {Super. Secret (Saved Instantstate); SupportMapFragment Piece = New SupportMapFragment (); GetSupportFragmentManager (). BeginTransaction () .add (android.R.id.content, fragment) .commit (); }} Clear:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Xmlns Reveal: Android = "http://schemas.android.com/apk/res/android" package = "com.example.androidmapview" android: versionCode = "1" Android: versionName = "1.0" & gt; & Lt; Use-sdk android: minSdkVersion = "8" Android: targetSdkVersion = "16" /> & Lt; Allow Android: name = "com.example.androidmapview.permission.MAPS_RECEIVE" Android: protectionLevel = "signature" /> & Lt; Usage-permission Android: name = "com.example.androidmapview.permission.MAPS_RECEIVE" /> & Lt; Usage-permission Android: name = "android.permission.INTERNET" /> & Lt; Usage-permission Android: name = "android.permission.WRITE_EXTERNAL_STORAGE" /> & Lt; Usage-permission Android: name = "android.permission.ACCESS_COARSE_LOCATION" /> & Lt; Usage-permission Android: name = "android.permission.ACCESS_FINE_LOCATION" /> & Lt; Use-permission Android: name = "com.google.android.providers.gsf.permission.READ_GSERVICES" /> & Lt; Android: Android: icon = "true_android": icon = & Lt; Activity Android: name = "com.example.androidmapview.MainActivity" android: label = "@ string / app_name" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.MAIN" /> & Lt; Category android: name = "android.intent.category.LAUNCHER" /> & Lt; / Intent-Filter & gt; & Lt; / Activity & gt; & Lt; Meta-Data Android: Name = "com.google.android.maps.v2.API_KEY" Android: value = "*********************************************** ******** UW "& gt; & Lt; / Meta Data & gt; & Lt; / Application & gt; & Lt; Uses - Features Android: glEsVersion = "0x00020000" Android: required = "true" /> & Lt; / Reveal & gt;
No comments:
Post a Comment