Android MapView显示黑屏

时间:2013-02-14 18:57:34

标签: android

我在我的应用中使用谷歌地图。我无法获得地图图块。我只看到一个黑屏。我现在已经挣扎了3天。我在我的计算机上生成了地图api密钥,并在myifest.xml文件中添加了所有权限。但仍然无法获得地图图块。 ActivityMap.java `

package com.example.locatometer;

import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;

import com.example.locatometer.utils.Tracker;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class ActivityMap extends MapActivity{
    MapView mapView;
    MapController controller;
    Tracker tracker;
    Handler locationHandler = new Handler();
    GeoPoint mapPoint;

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.activity_current_location_on_map);
        init();
    }
    private void init() {
        mapView = (MapView) findViewById(R.id.map);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(true);
        controller = mapView.getController();

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

    }
    @Override
    protected void onPause() {
        super.onPause();

    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

}
`

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/map"
        android:clickable="true"
        android:apiKey="******************************" />

</LinearLayout>

的manifest.xml

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

    <uses-sdk
        android:minSdkVersion="5"
        android:targetSdkVersion="10" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/LocatometerTheme" android:debuggable="true">
        <uses-library android:name="com.google.android.maps"/>
        <activity
            android:name="com.example.locatometer.ActivitySplash"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.example.locatometer.ActivityMenu"></activity>
        <activity android:name="com.example.locatometer.ActivityCurrentLocation"></activity>
        <activity android:name="com.example.locatometer.ActivityMap"></activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

它可能没有关系,但是当我面对类似的问题时,我做过一次。在manifest put

中的应用程序标记下
  android:hardwareAccelerated="false"

可能不行,但值得一试。