集成
gradle引用
#在项目的build.gradle中加入jcenter库
allprojects {
repositories {
google()
jcenter()
}
}
#在app目录的build.gradle中加
compile 'com.jason.simple:jsBridge:1.0.2'
使用
直接继承LightAppActivity并实现JsBridgeInterface接口,就可以直接进行使用
public class DemoActivity extends LightAppActivity implements JsBridgeInterface
#在Activity的onCreate方法里调用
setInterface(this)
#然后就可以直接调用
loadUrl("https://www.baidu.com")
setTitle("") 改变title
....还有一些其他方法等等
关于plugin类,是用于与web交互的实体类,自定义plugin类需要继承JsPlugin类
public class DemoPlugin extends JsPlugin {
private Handler handler;
private JsBridgeWebView webView;
private Context mContext;
public DemoPlugin(Handler handler, Context mContext, JsBridgeWebView webView) {
super(handler, mContext, webView);
this.handler = handler;