1

I have an Android project with two activities. One is my main activity, using a GLSurfaceView that gets updated from native code. The other is a PurchaseActivity that opens up Google's In-App Billing client to make purchases. Making purchases works fine.

The problem I'm running into is that after the PurchaseActivity finishes, whether it completes successfully, errs, or is cancelled, and it switches back to the main activity, the EGL context disappears and I receive:

call to OpenGL ES API with no current context (logged once per thread)

After that the onSurfaceCreated() and onSurfaceChanged() methods are retriggered.

I found this question similar but mine is already running in a separate activity and if I remove the finish() call, it just remains stuck in the PurchaseActivity.

Do I really need to reload the textures after making an in-app billing call? It seems this shouldn't be necessary at this point since the app is not being suspended.

My renderer code is pretty basic but for whatever reason, after the billing client window closes, it triggers a new surface and blows up my native code:

public class GameRenderer implements GLSurfaceView.Renderer
{   
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    { }

    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        BaseLib.setScreenSize(width, height);
        BaseLib.init();
    }

    public void onDrawFrame(GL10 gl)
    {
        BaseLib.render();
    }
}
Community
  • 1
  • 1
Nick Gotch
  • 9,167
  • 14
  • 70
  • 97

1 Answers1

1

Have you seen this thread?

Prevent onPause from trashing OpenGL Context

I would guess you get an onPause when you switch activities, which tells the GLSurfaceView to release resources.

On API 11+ there is a command setPreserveEGLContextOnPause, but not sure if that's a solution for you if you want to target lower API levels than that.

Community
  • 1
  • 1
Tim
  • 35,413
  • 11
  • 95
  • 121