How Do You Use WebMessagePort As An Alternative to addJavascriptInterface()?

后端 未结 4 832
不思量自难忘°
不思量自难忘° 2020-12-10 03:42

Google\'s security guidelines for Android app developers has the following:

WebViews do not use addJavaScriptInterface() with untrusted cont

4条回答
  •  误落风尘
    2020-12-10 04:27

    @CommonsWare I have tried your solution and it worked for me. Just one little addition. You can use loadUrl() too, by setting Uri argument to Uri.EMPTY. Working on Nexus 7 (MOB30J).

        getWebView().postWebMessage(new WebMessage("MESSAGE", new WebMessagePort[]{
                channel[1]
        }), Uri.EMPTY);
    

提交回复
热议问题