2012-11-20 63 views
0

我正在瀏覽移動地圖應用程序的Google教程。 我設法在Android虛擬手機中編譯和運行我的應用程序:安卓地圖第一個程序

5.4 FWVGA(480x854:mdpi)。

當我真的在手機中啓動應用程序時,我只是得到一個帶有平方背景(如幾何紙)的空白地圖。

我的感覺是,什麼是錯在這裏:

RES /佈局/ activity_main.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" 
    tools:context=".MainActivity" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="@string/hello_world" /> 

</RelativeLayout> 

RES /佈局/ main.xml中:

<?xml version="1.0" encoding="utf-8"?> 
<com.google.android.maps.MapView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    android:apiKey="blablabla" 
/> 

的AndroidManifest.xml :

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

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="16" /> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme"> 
     <uses-library android:name="com.google.android.maps"/> 
     <activity 
      android:name=".HelloGoogleMaps" android:label="@string/app_name" 
      android:theme="@android:style/Theme.NoTitleBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
</manifest> 

所以要清楚,我如何讓我的應用程序連接到互聯網並加載磁貼?

感謝

jenia

回答

1

假設你有獲得了項目中引用的Google API,但是你的沒有獲得了API密鑰 - 轉到here並使用this documentation指導您完成項目的使用準備!

2

除了檢查,上網權限清單文件授予(it's我用的時候我開始開發新的應用程序,以忘記的事),就是你的關鍵在專門爲調試目的而創建的MapView對象的apiKey屬性中使用?如果情況並非如此,即使您仍然可以與MapView進行交互,您將無法看到拼貼。