Maintaining glSurfaceView through different activities

150 views Asked by At

I am writing an android app with opengl-es and i came across a problem.... I found out that you should not send a view from one activity to another. My app includes several activities and I would like to share a single glsurface view among the activities.....

Is there any way to achieve this?

1

There are 1 answers

0
fadden On BEST ANSWER

Not really.

When you switch Activities, all of the View-based UI for the old Activity is torn down, and the View elements for the new Activity are created. GLSurfaceView takes care of creating and destroying the EGL context as well.

There are ways to keep surfaces around by playing games with TextureView (see e.g. Grafika's "double decode", which continues playing video while the Activity is restarted for device orientation changes), but I doubt that will be the best approach for your app.

You should either merge Activities or handle the GLSurfaceView restart.