Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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());

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top