Java nullpointer exception from Webview in android.webkit.WebViewClassic.loadDataWithBaseURL

Following the recommendations in this question , I modified my AdMob code to fit the recommendations that worked effectively, reducing the number of exceptions that occurred. However, the new exception is growing.

The code is as follows:

@Override
protected void onDestroy() {
    if ( adView != null ) {
          adView.destroy();
          adView = null;

          Log.i(ApplicationData.APP_TAG, TAG + ": OnDestroy, destroying the Adview");
     }

    super.onDestroy();
}

The method adView.destroy()seems to work well when a LogCat post is posted. Immediately after this post, I get the following exception in WebView:

java.lang.NullPointerException
    at android.webkit.WebViewClassic.loadDataWithBaseURL(WebViewClassic.java:2741)
    at android.webkit.WebView.loadDataWithBaseURL(WebView.java:919)
    at com.google.android.gms.ads.internal.request.n.run(SourceFile:206)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:153)
    at android.app.ActivityThread.main(ActivityThread.java:5297)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    at dalvik.system.NativeStart.main(Native Method)

Fortunately, I cannot find a way to reproduce the problem, but it is regularly produced. I was not able to find any problem, is there any hint of what I can do?

+4
2
+5

, WebView loadDataWithBaseUrl (, ). AdMob ,

public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
        synchronized(this) {
            if(!this.isDestroyed()) {
                super.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
            } else {
                Log.d("The webview is destroyed. Ignoring action.");
            }

        }
    }

.

+2

All Articles