我有一个带有一些代码的glsurfaceview渲染器,可以让我在按下主页按钮后恢复并再次进入游戏,并且效果很好,但是如果我使用返回按钮关闭游戏,然后我再次尝试进入游戏,它就会崩溃并关闭。我试过在 OnDestroy 上写 finish() 但没有用。我已经检查了 onDestroy() 在我按下返回按钮时执行它。在 onSurfaceCreated 我有加载纹理并设置顶点以绘制这些纹理的函数,但是,我不明白会发生什么
编辑:
这是我第二次启动游戏后的日志,之前关闭过
05-08 20:30:41.069: I/GLThread(6272): noticed surfaceView surface lost tid=12
05-08 20:30:41.069: I/GLThread(6272): onResume tid=12
05-08 20:30:41.169: I/GLThread(6272): noticed surfaceView surface acquired tid=12
05-08 20:30:41.169: W/EglHelper(6272): start() tid=12
05-08 20:30:41.219: W/EglHelper(6272): createContext com.google.android.gles_jni.EGLContextImpl@4056d398 tid=12
05-08 20:30:41.219: I/GLThread(6272): noticing that we want render notification tid=12
05-08 20:30:41.219: W/GLThread(6272): egl createSurface
05-08 20:30:41.219: W/EglHelper(6272): createSurface() tid=12
05-08 20:30:41.219: W/GLThread(6272): onSurfaceCreated
05-08 20:30:41.219: W/GLThread(6272): onSurfaceChanged(480, 320)
05-08 20:30:41.379: W/EglHelper(6272): destroySurface() tid=12
05-08 20:30:41.389: W/EglHelper(6272): finish() tid=12
05-08 20:30:41.389: W/dalvikvm(6272): threadid=9: thread exiting with uncaught exception (group=0x40018578)
05-08 20:30:41.389: E/AndroidRuntime(6272): FATAL EXCEPTION: GLThread 12
05-08 20:30:41.389: E/AndroidRuntime(6272): java.lang.NullPointerException
05-08 20:30:41.389: E/AndroidRuntime(6272): at glfg.gl.render.setverticesSquare(render.java:180)
05-08 20:30:41.389: E/AndroidRuntime(6272): at glfg.gl.render.onSurfaceChanged(render.java:475)
05-08 20:30:41.389: E/AndroidRuntime(6272): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1381)
05-08 20:30:41.389: E/AndroidRuntime(6272): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)
05-08 20:30:41.399: I/GLThread(6272): onPause tid=12
如果我终止进程,我可以毫无问题地再次进入,但是如果我使用返回按钮退出,当我尝试再次启动它时它会崩溃,它应该是应用程序将完全关闭但似乎不是