Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8100951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:52:07+00:00 2026-06-05T22:52:07+00:00

On android, the GLSurfaceView documentation says this: A GLSurfaceView must be notified when the

  • 0

On android, the GLSurfaceView documentation says this:

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.

So I’m supposed to do something like this in my activity:

public void onPause() {
    myGlSurfaceView.onPause();
}

public void onResume() {
    myGlSurfaceView.onResume();
}

I’m observing in my code that if I don’t call onPause() and onResume() 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.

So my question is: when is the OpenGL context destroyed? If I don’t call onPause() and onResume() can I assume that it will never be destroyed?

EDIT:

I’m targeting Android 2.2, so setPreserveEGLContextOnPause() is not an option to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:52:08+00:00Added an answer on June 5, 2026 at 10:52 pm

    The OpenGL might be lost only after Actvity::onPause() is called, and only in this case. See the setPreserveEGLContextOnPause documentation :

    Whether the EGL context is actually preserved or not depends upon whether the Android device that the program is running on can support an arbitrary number of EGL contexts or not. Devices that can only support a limited number of EGL contexts must release the EGL context in order to allow multiple applications to share the GPU.
    […] the EGL context [can be] released when the GLSurfaceView is paused, and recreated when the GLSurfaceView is resumed.

    EDIT : The situation described in the documentation is valid on all Android version. Not matter you have access to setPreserveEGLContextOnPause

    In my opinion, this is one major drawback is Android OGLES implementation : you can’t be certain.

    The documentation itself is vague (EGL Context Lost note) :

    There are situations where the EGL rendering context will be lost. This typically happens when device wakes up after going to sleep

    I noticed the same behavior as you about the Home and Back button. Calls are not exactly the sames (but can’t remember them precisely).

    The only way to be sure that the OpenGL context is available is to create all OpenGL resources in onSurfaceCreated

    Note about setPreserveEGLContextOnPause. Once again, this documentation comment demonstrates the “random” behavior of context destruction :

    If set to true, then the EGL context may be preserved when the GLSurfaceView is paused. […]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to utilize setDebugFlags as recommended here to scan for opengl errors: http://developer.android.com/resources/articles/glsurfaceview.html
Android newbie here. I'm using this tutorial to show some rows that I fetch
The GLSurfaceView.Renderer interface of the Android SDK gives me a GL interface as parameter
Is there any way in Android to use a GLSurfaceView to display the camera
I have a Activity class and a Renderer class (extends GLSurfaceView implements Renderer). Inside
I've created 3 Java classes. one that has a glsurfaceview object and this calls
Basically i have an application for Android 1.5 with a GLSurfaceView class that shows
So I followed this tutorial from Google: http://developer.android.com/resources/tutorials/opengl/opengl-es20.html The triangle is supposed to rotate
I'm new on Java and Android programming language and this is the first platform
So I'm making an Android 2.2 app that uses GLSurfaceView. My question is, since

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.