在我的应用程序中,我随机遇到以下崩溃:
java.lang.NullPointerException
android.view.SurfaceView.updateWindow(SurfaceView.java:498)
android.view.SurfaceView.updateWindow(SurfaceView.java:412)
android.view.SurfaceView.access$000(SurfaceView.java:89)
android.view.SurfaceView$1.handleMessage(SurfaceView.java:131)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:130)
android.app.ActivityThread.main(ActivityThread.java:3691)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:507)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
dalvik.system.NativeStart.main(Native Method)
(安卓 2.3.6)
有没有人知道如何调试它?
请注意,我需要在我的表面上做一些奇怪的事情,以使其在脱离层次结构时保持活力,例如:
private boolean detachFromParent = false;
@Override
protected void onDetachedFromWindow() {
if(detachFromParent) {
super.onDetachedFromWindow();
}
}
public void destroy() {
if(getParent() != null) {
detachFromParent = true;
((ViewGroup) getParent()).removeView(this);
detachFromParent = false;
}
}