libgdx/libgdx — pull request #859 by davebaol (2013-10-23 09:28:20+00:00)
Title: Updated GLSurfaceViewCupcake to GLSurfaceView from Android 4.3 (API 18) so to properly support onAttachedToWindow and onDetachedFromWindow

In my project I have to attach/detach the gdx surface view to/from different layouts.
It works great on all Android 4.x I've tested, actually API 15 and newer.
Unfortunately id doesn't work on older Android versions, I tested 2.2 and 2.3.3.
Especially in logcat I get weird errors about surface identity different from the expected one and the app crashes.
Note that all my tests are done on real devices.

I've started investigating and tracked down the issue. The class GLSurfaceViewCupcake is definitely responsible for the crash and the issue disappears after updating it to API 18 .

Relevant changes done to android.opengl.GLSurfaceView from Android 4.3 (API 18) and/or taken from the last version of GLSurfaceViewCupcake:

1. Added ResolutionStrategy to constructors.
2. Overridden onMeasure method so to use the specified resolution strategy.
3. Set format and type of the SurfaceHolder based on android sdk version.
4. Commented Renderer and EGLConfigChooser interfaces since we have to use the ones from GLSurfaceView.
5. In checkGLESVersion forced openGL ES version to a value lower than 2.0 because we can't use the hidden class SystemProperties.
If Libdgx already has its own method to detect the openGL version supported by the device we might use it here.

Further notes:
By looking at the code I think that issues 704 and 715 are already fixed in API 18, not tested though.