【问题标题】:FragmentActivity showing blank map on device, what could be the reason behind that?FragmentActivity 在设备上显示空白地图,这可能是什么原因?
【发布时间】:2013-05-27 18:52:57
【问题描述】:

我的问题是我的 android 设备 2.3.0 上没有显示谷歌地图 我是 android 新手,我正在尝试在我的应用程序中使用 google map,我已经下载了 google play 服务,还添加了 adndroidsupportv4.jar,我使用 sha1 生成了 api 密钥,完成所有步骤后,地图在设备上不可见,这背后可能是什么问题,任何人都可以帮助我。即使我已经下载了 google play services emulator 显示一个错误,即未安装 google play services,所以我在开发 google map 应用程序时犯了错误

My code is:
below is the MainActivity class


package com.example.androdemo;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {
    GoogleMap map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        map =((SupportMapFragment)
                (getSupportFragmentManager().findFragmentById(R.id.map) )).getMap();
       // map.setMapType(GoogleMap.MAP_TYPE_HYBRID);

    }


}

activity_main.xml 

<LinearLayout 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" >

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

</LinearLayout>

AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <permission
        android:name="com.example.androdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.example.androdemo.permission.MAPS_RECEIVE"/>

    <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="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
    <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" >
        <activity
            android:name="com.example.androdemo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data 
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyB62caTnqcZoZil2lBc_qinUfNKNDmijRI"/>

    </application>



</manifest>

【问题讨论】:

标签: android google-maps android-fragments android-maps-v2


【解决方案1】:

我遇到了同样的问题,解决方法是生成一个签名的 apk 以查看地图。我不能只在运行或调试时查看它。必须是已签名的应用程序。

【讨论】:

    【解决方案2】:

    要检查的另一件事是您的 android 设备上是否可以使用互联网。

    我正在开发一个使用谷歌地图的应用程序,他们一直在工作。当他们突然没有出现时,我不知道发生了什么。原来是没有网络连接导致了这个问题!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-05
      • 2021-09-12
      相关资源
      最近更新 更多