title: Prevent EGLContext to be destroyed when going to background
body: <p>My Android (OpenGL ES 2.0) game needs to be paused when user is minimizing it, without destroying what is already drawn on screen. Originally it used NativeActivity and pure C++, but it looks like it is not possible there. I have rewritten it and it is now Java generating custom GLSurfaceView and game logic+rendering is in C++. I added <em>setPreserveEGLContextOnPause(true)</em> when surface is created. </p>
  
  <p>So the flaw after user click Home button is:</p>
  
  <ol>
  <li><em>onPause</em> is sending <em>nativeOnPause</em> to C++ code through JNI</li>
  <li>C++ code sets pause variable which prevents updating and rendering</li>
  </ol>
  
  <p>This works ok. After we get back to app:</p>
  
  <ol>
  <li><em>onResume</em> calls <em>nativeOnResume</em></li>
  <li>nativeOnResume calls EGL methods to get current context, display and surface and pass that to game manager.</li>
  <li>Updating and rendering is now activated</li>
  <li>We get few <em>EGL_BAD_SURFACE</em> messages and finally crash on <em>eglMakeCurrent</em></li>
  </ol>
  
  <p>The question is: should we in any way recreate EGLSurface and EGLDisplay using current context, or getting current surface and display is fine?</p>
  
  <p>I also noticed that when we get back to app, <em>onResume</em> is called, but <em>onSurfaceChanged</em> or <em>onSurfaceCreated</em> is not called.</p>
  
  <p>Any suggestion how to approach that problem on >4.0 devices?</p>