title: Android: When is OpenGL context destroyed?
body: <p>On android, the <code>GLSurfaceView</code> documentation says this:  </p>
  
  <blockquote>
    <p>A GLSurfaceView must be notified when the activity is paused and
    resumed. GLSurfaceView clients are required to call onPause() when the
    activity pauses and onResume() when the activity resumes. These calls
    allow GLSurfaceView to pause and resume the rendering thread, and also
    allow GLSurfaceView to release and recreate the OpenGL display.</p>
  </blockquote>
  
  <p>So I'm supposed to do something like this in my activity:</p>
  
  <pre><code>public void onPause() {
      myGlSurfaceView.onPause();
  }
  
  public void onResume() {
      myGlSurfaceView.onResume();
  }
  </code></pre>
  
  <p>I'm observing in my code that if I don't call <code>onPause()</code> and <code>onResume()</code> then the context is not lost when I press the home button, so I can switch between applications and then go back to my game and everything is working. What I see is that if I close the game using the back button then the screen is black when I open it again, but I can change the back button behaviour to totally close the game and avoid this problem.</p>
  
  <p>So my question is: when is the <em>OpenGL</em> context destroyed? If I don't call <code>onPause()</code> and <code>onResume()</code> can I assume that it will never be destroyed?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'm targeting Android 2.2, so <code>setPreserveEGLContextOnPause()</code> is not an option to me.</p>