SurfaceView在关闭时崩溃

时间:2014-02-12 22:48:12

标签: android crash surfaceview

当我尝试结束应用程序时,我的自定义SurfaceView类崩溃了。当按下“home”或“back”时,应用程序将结束,但通知我:“'游戏'已经崩溃”

如何正确结束Surfaceview?

提前致谢

logcat:

02-12 23:51:07.661: D/OpenGLRenderer(32561): Enabling debug mode 0
02-12 23:51:09.450: W/dalvikvm(32561): threadid=11: thread exiting with uncaught exception (group=0x41eaeb90)
02-12 23:51:09.450: E/AndroidRuntime(32561): FATAL EXCEPTION: Thread-1321
02-12 23:51:09.450: E/AndroidRuntime(32561): Process: com.ochs.x, PID: 32561
02-12 23:51:09.450: E/AndroidRuntime(32561): java.lang.NullPointerException
02-12 23:51:09.450: E/AndroidRuntime(32561):    at android.view.SurfaceView.dispatchDraw(SurfaceView.java:343)
02-12 23:51:09.450: E/AndroidRuntime(32561):    at android.view.View.draw(View.java:14436)
02-12 23:51:09.450: E/AndroidRuntime(32561):    at android.view.SurfaceView.draw(SurfaceView.java:334)
02-12 23:51:09.450: E/AndroidRuntime(32561):    at com.ochs.x.GameView.draw(GameView.java:109)
02-12 23:51:09.450: E/AndroidRuntime(32561):    at com.ochs.x.GameThread.run(GameThread.java:25)
02-12 23:51:09.575: W/IInputConnectionWrapper(32561): showStatusIcon on inactive InputConnection

这是我的绘图方法:

public void draw(Canvas canvas) {
    super.draw(canvas);
    Paint textPaint = new Paint();
    textPaint.setColor(Color.BLACK);
    textPaint.setTextSize(30);
    canvas.drawColor(Color.WHITE);
    canvas.drawText("mX: " + mx, 10, 30, textPaint);
    canvas.drawText("mY: " + my, 10, 70, textPaint);
    canvas.drawText("calX: " + calibrationX, 10, 110, textPaint);
    canvas.drawText("calY: " + calibrationY, 10, 150, textPaint);

}

几个月前我已经遇到了同样的问题,但我忘了如何正确关闭包含自定义表面视图的活动......

0 个答案:

没有答案