-2

私は他の提案を試しましたが、運がありません。APIキーはすでに何度も変更しています。

私のMapActivity.javaのコードはこちら

package com.santehfeedsgis;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MapActivity extends FragmentActivity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_map);
 }

}

私のレイアウトの activity_map.xml コード

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

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

</RelativeLayout>

マニフェスト AndroidManifest.xml コードのコードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.santehfeedsgis"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="12"
    android:targetSdkVersion="17" />

<permission 
    android:name="com.santehfeedsgis.permission.MAPS_RECEIVE" 
    android:protectionLevel="signature"></permission>
<uses-permission 
    android:name="com.santehfeedsgis.permission.MAPS_RECEIVE"/>
<uses-permission 
    android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission 
    android:name="android.permission.INTERNET"/>
<uses-permission 
    android:name="android.permission.ACCESS_NETWORK_STATE"/>    
<uses-permission 
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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"/>


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="mysecretkeyhere/>

    <activity
        android:name="com.santehfeedsgis.MapActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

4

3 に答える 3

1

最小 SDK は 12 です。標準を拡張しますActivity。使用できますMapFragment

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

また、Google API コンソールで andorid のマップが有効になっていることを確認し、以下のリンクのすべての手順に従っていることを確認してください。

https://developers.google.com/maps/documentation/android/start

最小 SDK が 11 以下の場合はSupportMapFragment、拡張する必要がある場合に使用する必要がありますFragmentActivtiy

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment

于 2013-08-04T17:29:21.453 に答える
0

これが役立つと思います。このリンクはフラグメント内の Google マップ用です

https://developers.google.com/maps/documentation/android/map?hl=pl#using_xml_attributes .

幸運を祈ります。

于 2013-08-04T17:21:49.137 に答える