web app 与java交互_Web APP - Java和js交互(web app与native app)

》WebView控件:WebViewClient或者WebChromeClient。

拦截URL请求,可以去请求网页,也可以进行其他处理(拼接参数 ,然后将参数拿出来)

> WebView: A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

> However, you shouldn't develop an Android app simply as a means to view your web site. Rather, the web pages you embed in your Android app should be designed especially for that environment. You can even define an interface between your Android application and your web pages that allows JavaScript in the web pages to call upon APIs in your Android application—providing Android APIs to your web-based application.

> 实现Java和js交互十分便捷。通常只需要以下几步(属于JS只有少数的几个,对于变动的以及很多的情况下不适合)

WebView开启JavaScript脚本执行

WebView设置供JavaScript调用的交互接口。

客户端和网页端编写调用对方的代码。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值