最近人们的应用开始出现问题。在webview中滚动页面时强制关闭。下面是他们发给我的堆栈跟踪。 请注意,空指针异常发生在系统提供的WebView代码中。任何人都知道可能出错了什么?如果需要,我会附上我的应用程序的任何部分的代码,这些代码可能与WebView代码中的失败有关。
java.lang.NullPointerException at
android.webkit.WebView.onTouchEvent(WebView.java:5351) at
android.view.View.dispatchTouchEvent(View.java:3952) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:995) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034) at
com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1711) at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1145)
at android.app.Activity.dispatchTouchEvent(Activity.java:2096) at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1695)
at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2217) at
android.view.ViewRoot.handleMessage(ViewRoot.java:1901) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:130) at
android.app.ActivityThread.main(ActivityThread.java:3701) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:507) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624) at
dalvik.system.NativeStart.main(Native Method)
感谢您的任何提示。
编辑:
我在页面加载时禁用了触摸侦听器,并在页面完成时启用它。
webView = new WebView(this);
webView.addJavascriptInterface(this, "DragonLords");
webView.setWebViewClient(webViewClient);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(1);
webView.loadData("<body style='background-color: black'> </body>", "text/html", "UTF-8");
webView.setOnTouchListener(this.disablingTouchListener);
private final OnTouchListener disablingTouchListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return webviewDisabled;
}
};