0

is it possible? Because onResume I get (example log):

I/dalvikvm-heap﹕ Grow heap (frag case) to 19.304MB for 8294416-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 27.213MB for 8294416-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 15.257MB for 4052160-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 17.277MB for 6169216-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 17.277MB for 6169216-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 17.277MB for 6169216-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 17.277MB for 6169216-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 17.277MB for 6169216-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 15.192MB for 3983200-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 19.304MB for 8294416-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 27.213MB for 8294416-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 16.059MB for 4892464-byte allocation
I/dalvikvm-heap﹕ Grow heap (frag case) to 19.303MB for 8294416-byte allocation

I assume it is because textures, sprites are reload, right? Resuming activity takes ~10 seconds on medium class device. I want decrease this time as much I can.

Is it right way to do it?

Błażej
  • 3,617
  • 7
  • 35
  • 62

2 Answers2

3

Ok I found it!

@SuppressLint("NewApi")
    @Override
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException {
        // TODO Auto-generated method stub
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            mRenderSurfaceView.setPreserveEGLContextOnPause(true);
        }
        initSplashScene();
        pOnCreateSceneCallback.onCreateSceneFinished(this.splashScene);

    }

This wil prevent openGL from losing context, so if you have context then openGL haven't reload all textures all over again.

But this works only for API 11 >. So or you set minimum API to 11 or do something about it. In my case I just make sure that update timers are being pause in onPause and resume in onResume if device API is < 11.

Błażej
  • 3,617
  • 7
  • 35
  • 62
  • I am also using the same to preserve context. Do you know how i can force a restart on resume if i detect change in preferences when it is paused? I have listeners implemented but don't know how to restart. – Shakti May 09 '14 at 06:08
  • @Shakti You mean restart EGLContext right? If yes I'm willingly to help you but you have to "ask question" :) – Błażej May 09 '14 at 09:29
0

Try to modify method onSetContentView() in BaseGameActivity.java with this code protected void onSetContentView() {

this.mRenderSurfaceView = new RenderSurfaceView(this);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
if(android.os.Build.VERSION.SDK_INT >= 11){
    this.mRenderSurfaceView.setPreserveEGLContextOnPause(true);
}
this.setContentView(this.mRenderSurfaceView, BaseGameFragmentActivity.createSurfaceViewLayoutParams());

}

Roman Soviak
  • 791
  • 2
  • 9
  • 30