1

由於新的Google Maps Android API V2需要Google Play服務,因此需要啓用「後臺數據」才能運行地圖應用嗎?當我不需要它時,我習慣關閉背景數據,因爲它會迅速殺死電池,並且我不希望我的應用程序要求啓用它。Android地圖api V2需要啓用背景數據嗎?

更新:花了一天的時間試圖研究這個:
- 安裝Android支持庫和谷歌播放服務SDK(哦,看,已經有更新修訂3可用)。 - 導入在https://developers.google.com/maps/documentation/android/intro#sample_code>處引用的示例代碼。
- 獲取新的maps v2 API密鑰並將其放入AndroidManifest.xml
- (重新)配置示例代碼,然後運行/調試它。
由於Play Services需要軟件無法內置到仿真器中,演示應用程序無法在仿真器上運行,並且似乎有很多工作要解決這個問題,或許是其他時間。所以我用Froyo在三星Intercept上進行了演示。 SupportMapFragment和/或com.google.android.gms.maps.MapView代碼讓我停止並更新Google Play服務APK。要做到這一點,我需要啓用「背景數據」(這是最初的問題)。之後,該應用程序允許我選擇各種地圖演示,但沒有一個顯示地圖。
的logcat中顯示:

 12-04 19:50:28.937: I/(18909): =======Chunk::PrintChunkBlckInfo ====== 
    12-04 19:50:28.937: I/(18909): libGLESv1_CM_fimg.so was unloaded and GLES 1.1 API was successfully unmapped 
    12-04 19:50:34.557: I/(18909): libGLESv1_CM_fimg.so was loaded and GLES 1.1 API was successfully mapped 
    12-04 19:50:34.562: I/(18909):
12-04 19:50:34.562: I/(18909): [Chunk Allocator] 1 blocks (block size:0x100000) 12-04 19:50:34.562: I/(18909):
12-04 19:50:34.562: I/(18909): =======Chunk::PrintChunkBlckInfo ====== 12-04 19:50:34.562: I/(18909):
12-04 19:50:34.562: I/(18909): ------------------------------------------------------ 12-04 19:50:34.562: I/(18909): [0] use flag: 1, start: 0, size: 1048576, next: 0x0 12-04 19:50:34.562: I/(18909):
12-04 19:50:34.562: I/(18909): ------------------------------------------------------ 12-04 19:50:34.562: I/(18909): Total Texture Size 0 Byte 0 KB Total Texture Count 0 12-04 19:50:34.562: I/(18909):
12-04 19:50:34.562: I/(18909): ------------------------------------------------------ 12-04 19:50:34.937: E/(18909): glCompressedTexImage2D(0xde1, 0, 0x8b96, 32, 8, 0, 1280, 0x0x369c70); 12-04 19:50:34.942: E/(18909): glCompressedTexImage2D(0xde1, 0, 0x8b96, 32, 8, 0, 1280, 0x0x379b90); 12-04 19:50:34.962: E/(18909): glCompressedTexImage2D(0xde1, 0, 0x8b96, 16, 1, 0, 1040, 0x0x347ac0);


所以現在,我還沒有一個明確的答案,不知道對不顯示在地圖的原因是否與我的密鑰生成/插入一個問題(沒有什麼可以指出在LogCat中),或者(更可能?)OpenGl的問題。

回答

2

這三件事情需要檢查。

  1. 設備是否已經安裝了谷歌服務:

    switch (GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)) { 
    case ConnectionResult.SUCCESS: 
        //Device has Google play services installed 
        break; 
    
    default: 
        break; 
    } 
    
  2. 不OpenGL ES 2.0的支持

    private boolean checkGL20Support(Context context) { 
    EGL10 egl = (EGL10) EGLContext.getEGL(); 
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); 
    
    int[] version = new int[2]; 
    egl.eglInitialize(display, version); 
    
    int EGL_OPENGL_ES2_BIT = 4; 
    int[] configAttribs = { EGL10.EGL_RED_SIZE, 4, EGL10.EGL_GREEN_SIZE, 4, 
         EGL10.EGL_BLUE_SIZE, 4, EGL10.EGL_RENDERABLE_TYPE, 
         EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; 
    
    EGLConfig[] configs = new EGLConfig[10]; 
    int[] num_config = new int[1]; 
    egl.eglChooseConfig(display, configAttribs, configs, 10, num_config); 
    egl.eglTerminate(display); 
    return num_config[0] > 0; 
    } 
    
  3. 驗證API密鑰是正確的 我。是否通過正確的調試密鑰和包產生密鑰ii。通過'Google Maps Android API v2'生成的密鑰不是'Google Maps API v2'enter image description here