WebView: Uncaught ReferenceError: Android is not defined

后端 未结 1 1863
遥遥无期
遥遥无期 2021-01-18 02:12

I am creating a WebView with code rather than loading via an XML layout. The webview appears to be created properly, but I am seeing the errors:

W/AwContent         


        
相关标签:
1条回答
  • 2021-01-18 02:53

    You didn't defined Android as a javascripinterface you have to write below lines

     // If your callback methods are in same class then just same class object
     webView.addJavascriptInterface(this, "Android");
    

    Syntax of addJavascriptInterface() method

          addJavascriptInterface(Object object, String name);        
       //  1. `object` – *the Java object to inject into this WebView’s JavaScript context.*
       //  2. `name` – *the name used to expose the object in JavaScript*
    
    0 讨论(0)
提交回复
热议问题