2013-02-14 156 views
2

我在我的應用程序中使用谷歌地圖。我無法獲得地圖圖塊。我只看到一個黑屏。我一直在掙扎3天。我在我的電腦上生成map api key,並在menifest.xml文件中添加了所有權限。但仍無法獲取地圖圖塊。 ActivityMap.java `Android MapView顯示黑屏

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> 
+0

同樣適用於我,2天我花時間在這... – Alexander 2016-02-26 10:36:12

回答

0

它可能不相關,但我這樣做一次,當我面臨着類似的問題的種類。清單中的應用標籤下放

android:hardwareAccelerated="false" 

可能不行,但值得一試。