Sometimes throws Uncaught Error: Error calling method on NPObject on Android

后端 未结 4 703
栀梦
栀梦 2020-12-24 07:35

I am having problems with the Webview in Android and it\'s JavascriptInterfaces.

I am passing a string to the JavascriptInterface. When debugging it, I receive the c

4条回答
  •  时光取名叫无心
    2020-12-24 07:46

    Operate iframe in Android 4.4 WebView may cause a similar exception(Uncaught ReferenceError: NPObject deleted), finally I find out the solution:

    @Override
    public void onPageFinished(final WebView view, String finishUrl) {
        super.onPageFinished(view, finishUrl);
        // android 4.4 may lost value of 'Android' when operating iframe
        view.addJavascriptInterface(Activity.this, "Android");
    }
    

提交回复
热议问题