0

我目前正在從舊的GoogleMaps API切換到較新的V2版本。我重構了舊的邏輯,它完美地工作。因爲我也支持2.1設備,所以我希望將舊的Map作爲舊設備或舊設備的傳統解決方案,而不使用PlayStore。在我來到HTC-Wildfire之前,我測試了很多設備。此設備已委託給MapsV2,但僅顯示空白的白色屏幕。我懷疑它不能渲染新的Map,因爲它缺少對OpenGlES的支持。GoogleMapsV2 OpenGL問題

這是我用來確定代碼地圖的版本應該得到所示:

int availCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); 
      switch (availCode) { 
      case ConnectionResult.SUCCESS: 
       addTab(TAB_GOOGLE_MAPS, R.string.tab_google_map, R.drawable.tab_surrounding, GoogleMapsActivityV2.class, true); 
       break; 
      case ConnectionResult.SERVICE_MISSING: 
      case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED: 
      case ConnectionResult.SERVICE_DISABLED: 
       GooglePlayServicesUtil 
       .getErrorDialog(availCode, this, REQUEST_CODE_PLAY_SERVICES) 
       .show(); 
       break; 
      case ConnectionResult.SERVICE_INVALID: 
      default: 
       addTab(TAB_GOOGLE_MAPS, R.string.tab_google_map, R.drawable.tab_surrounding, GoogleMapsActivity.class, true); 
       break; 
      } 

所以它擁有GooglePlayServices支持,但obviosly此檢查不enaugh。是否可以檢查支持的OpenGL-ES版本?我應該檢查什麼才能讓舒爾MapsV2是runnig?我無法在清單中定義requiresFeature openGLES標記,因爲我有一個傳統回退,並且不想排除不喜歡PlayStore的低端設備或用戶。

+0

Android 2.1及更低版本[不到所有設備的1%](http://developer.android.com/about/dashboards/index.html)確定您需要支持該功能? – WarrenFaith

+0

不,我們打算把它放到2.2。但即使在2.2版本中,仍然存在沒有PlayStore或OpenGL的設備,無法顯示新的GMapsV2 –

回答

1

這確實一個綱領性的檢查對OpenGL/ES 2支持:

// Check device configuration to ensure OpenGL ES 2.0 support 
ActivityManager am = (ActivityManager)activity.getSystemService(Context.ACTIVITY_SERVICE); 
ConfigurationInfo config = am.getDeviceConfigurationInfo(); 
if (config.reqGlEsVersion < 0x20000) 
{ 
addTab(TAB_GOOGLE_MAPS, R.string.tab_google_map, R.drawable.tab_surrounding, GoogleMapsActivity.class, true); 
} 
else 
{ 
... check for Play Services... 
} 

您也可以要求通過您的應用清單的OpenGL/ES 2支持:

<uses-feature android:glEsVersion="0x00020000" android:required="true" /> 

儘管這會產生衝突的渴望支持Android 2.1。