有可能吗?因为onResume我得到(示例日志):
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
我认为这是因为纹理,精灵正在重新加载,对吧?在中型设备上恢复活动需要大约10秒。我希望尽可能减少这次。
这是正确的方法吗?
答案 0 :(得分:3)
好的,我找到了它!
@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);
}
这会阻止openGL丢失上下文,所以如果你有上下文,那么openGL没有重新加载所有纹理。
但这仅适用于API 11>。所以,或者你将最低API设置为11或做些什么。 在我的情况下,我只是确保更新计时器在onPause中暂停,并在onResume中恢复,如果设备API是< 11。
答案 1 :(得分:0)
尝试在BaseGameActivity.java中修改onSetContentView()方法 用这个代码 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());
}