2013-02-16 240 views
0

我正在整合谷歌地图在我的应用程序。当我编译和朗姆我的应用程序在模拟器上它显示我黑屏。我添加了所需的权限并在清单中添加了user-library标记,但仍显示黑屏。这里是我的代码MapView显示黑屏

public class ActivityLiveMap extends MapActivity { 
    private LocationManager locationManager; 
    private Location location; 
    private List<Overlay> overlayList; 
    private GeoPoint mapPoint; 
    private MapController controller; 
    private MapView map; 

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

    private void init() { 
     map = (MapView) findViewById(R.id.map); 
     map.setBuiltInZoomControls(true); 
     map.setSatellite(true); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     // TODO Auto-generated method stub 
     return false; 
    } 
} 

的manifest.xml

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

    <uses-sdk 
     android:minSdkVersion="5" 
     android:targetSdkVersion="10" /> 

    <supports-screens 
     android:anyDensity="true" 
     android:largeScreens="true" 
     android:normalScreens="true" 
     android:resizeable="true" 
     android:smallScreens="true" /> 

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

    <supports-screens 
     android:largeScreens="true" 
     android:normalScreens="true" 
     android:smallScreens="true" /> 

    <application 
     android:allowBackup="true" 
     android:debuggable="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/Theme.LocationMeter" > 
     <uses-library android:name="com.google.android.maps"/> 
     <activity 
      android:name="com.example.locationmeter.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=".ActivityMenu" > 
     </activity> 
     <activity android:name=".ActivityCurrentLocation" > 
     </activity> 
     <activity android:name=".ActivityLiveMap"></activity> 
    </application> 

</manifest> 

请帮帮我,谢谢

+1

有你得到了应用键? – 2013-02-16 10:07:58

+0

是的,我得到了调试API密钥。当我第一次运行应用程序时,它显示的是瓷砖。但是当我添加覆盖图时,它开始显示黑屏。即使我删除添加覆盖的所有代码后,它仍然显示黑屏 – 2013-02-16 10:11:14

+0

你有没有尝试清理并再次运行项目? – 2013-02-16 10:14:36

回答

0

你能确保你有:

- debug key 
- internet permission 
- internet enabled 
+0

我得到了调试密钥并添加了权限。但我认为我的模拟器上没有启用互联网。我尝试了新的模拟器,现在它的工作正常 – 2013-02-16 10:37:14