人们最近开始对我的应用程序有问题。当他们在 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;
}
};