Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm displaying a dialogue over my GLRenderer and then dismissing it from my Renderer's onSurfaceChanged method (once all resources have loaded and just before rendering starts)

When I first run my app - all works great, my loading screen is displayed while all my resources / textures load.

However, using the code below, when I press the home key and resume the app, all I get is the loading screen - it never actually disappears, and the renderer never actually starts again (I've confirmed this, onSurfaceCreated doesn't even run).

If I create a new 'myView' object (again, you can see this line in the code, commented out), then it does work. However, this is out of the question and shoudn't be necessary anyway.

So, how can I get it to run like it does the first time (without creating a new GLRenderer each and every time and also while displaying my loading graphic?)

PS (if I remove the setContentView() line from the onRestart method, then it does run but the dialog doesn't come up, it only flashes up for a split second)

Any help would be appreciated

protected void onCreate(Bundle savedInstanceState) {

//Full screen


//Create a displayMetrics object to get pixel width and height
DisplayMetrics metrics = new DisplayMetrics();
width = metrics.widthPixels;
height = metrics.heightPixels;

//Create splash-screen object and pass in scaled width and height
splash = new SplashScreen(MainActivity.this, width, height);

//Create dialog that will show splash-screen 
loading_dialog = new Dialog(MainActivity.this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);

//Set and display splash screen view (Note here is were I create the initial render object

//Create and set GL view (OpenGL View)
myView = new MyGLSurfaceView(this);


On Start

protected void onRestart() {
// TODO Auto-generated method stub
//Create dialog that will show splash-screen 

//Code breaks without this line, but I can't have this line here as it causes other issues *

//myView = new MyGLSurfaceView(this);


//I can remove this line too but it doesn't make any difference, again dialogue is displayed but nothing else (ie, it never disappears)

share|improve this question
I don't know Android's APIs, but is onSurfaceCreated being handled appropriately? Remember that a context can be "lost" meaning you need to reload all your assets and recreate all your buffers. –  Sean Middleditch Jun 19 '13 at 19:50
Hi @SeanMiddleditch, yeah, the EGL context is (more than likely) lost when onPaused() is called. I'm not sure what you mean by is 'onSurfaceCreated' being 'handled correctly' though? In my onSurfaceCreated method I am (re)loading all of my openGL textures (as recommended by Google). The problem here is that when I resume my app, it never gets to onSurfaceCreated (if I show my loading dialog) because the renderer doesn't run, the app seems to simply 'stop' at onResume(). If I don't show my dialog, then all is OK - any suggestions would be a great help - thanks! –  user22241 Jun 19 '13 at 20:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.