1

我创建了一个活动,我展示了谷歌地图。我在下面的链接中完成所有这些步骤。

http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/

当我在三星 Galaxy Note 2 上尝试时,我得到了这个截图:

在此处输入图像描述

但是当我在三星 Galaxy Note 10.1 上尝试时,我得到了这个(没有显示地图,只有缩放按钮):

在此处输入图像描述

这是我的Manifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.app"
     android:versionCode="1"
     android:versionName="1.0" >
<permission
    android:name="com.example.googlev2map.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.googlev2map.permission.MAPS_RECEIVE" />

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <activity
        android:name="com.android.app.SplashScreenLoading"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.android.app.Map"
        android:label="@string/title_activity_map" >
    </activity>

    <!-- Goolge Maps API Key -->
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyAvlLrKpq0Pf-6xzzHqtq-XattJ_zf58pk" />
</application>

</manifest>

这是我的Map.java代码:

   package com.android.tuyap;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Typeface;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class Map extends FragmentActivity {
    // Google Map
    private GoogleMap googleMap;

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

        try {
            // Loading map
            initilizeMap();

        } catch (Exception e) {
            e.printStackTrace();
        }

        double latitude = 41.020133;
        double longitude = 28.542910;

        // create marker
        MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Marker title");

        // adding marker
        googleMap.addMarker(marker);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude),15));
    }

    private void initilizeMap() {
        if (googleMap == null) {
            SupportMapFragment fm = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map));
            googleMap=fm.getMap();
            // check if map is created successfully or not
            if (googleMap == null) {
                Toast.makeText(getApplicationContext(),
                        "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        //getMenuInflater().inflate(R.menu.map, menu);
        return true;
    }
    }

和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"
        android:background="@drawable/splash_screen_background"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >

        <LinearLayout
            android:id="@+id/headerLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/main_menu_gradient_header"
            android:orientation="horizontal" >

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:layout_weight="2" >

                <ImageView
                    android:id="@+id/backButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:layout_margin="5dp"
                    android:src="@drawable/back_button" />

            </RelativeLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/txtSubHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:text="Text Header"
                    android:textSize="@dimen/SubHeaderTextSize" />

            </RelativeLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:layout_weight="2" >

                <ImageView
                    android:id="@+id/mainMenuButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:layout_margin="5dp"
                    android:src="@drawable/main_menu_button" />

            </RelativeLayout>
        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/headerLayout"
            android:orientation="vertical"
            android:weightSum="2" >

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

        </RelativeLayout>

    </RelativeLayout>

为什么我无法在 Galaxy Note 10.1 平板电脑上显示地图?

4

1 回答 1

2

Try to uninstall the app and install it again,当您在清单文件中更改并直接在设备上测试而不卸载以前安装的应用程序时,可能会发生这种情况。这次也试着清理你的项目。只有当您的清单文件或任何 xml 文件不会被反映时才会发生这种情况您忘记清理项目或卸载以前的项目,设备不适合工作或不工作谷歌地图。

于 2013-10-30T13:32:30.423 回答