美文网首页
AgentWeb JS 调用安卓 安卓 调用JS

AgentWeb JS 调用安卓 安卓 调用JS

作者: 风就那么大 | 来源:发表于2023-09-03 16:38 被阅读0次
        agentWeb.getJsInterfaceHolder().addJavaObject("testApp", AndroidInterface())



  inner class AndroidInterface {
        @JavascriptInterface
        fun showAppMessage(s: String) {
            Toaster.show("安卓JS点击了" + s)
            Handler().postDelayed({
                agentWeb.getJsAccessEntrace().quickCallJs("androidShowMessage", "55555555555")
            }, 3000)
        }
    }



<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试交互</title>
</head>

<body>

    <button  onclick="testShow()">点击调用</button>


    <script>


        function testShow() {
            alert('点击了')
            testApp.showAppMessage('66666666666')
        }

         function androidShowMessage(data) {
            alert(data)
        }


    </script>

</body>

</html>



相关文章

网友评论

      本文标题:AgentWeb JS 调用安卓 安卓 调用JS

      本文链接:https://www.haomeiwen.com/subject/xdtlmdtx.html