ZebView
Bridge between javascript and java on Android WebView
Get Start
There are two parts for getting start
Android Part
Add jitpack repository
repositories {
maven { url 'https://jitpack.io' }
}
Add dependency
dependencies {
implementation "site.zbyte:zebview:${version}"
}
Create ZebView in layout xml file or by java code(kotlin)
//Create ZebView
val zv=ZebView(context)
//Add Service
zv.addService("TestService",TestServiceObject)
.addService("SecondService",SecondServiceObject)
//Load your page
zv.loadUrl("http://192.168.0.137:3000")
Frontend Part
See zebview-bridge
Support Params Type
Javascript -> Java
- Number -> Integer/Long
- String -> String
- Boolean -> Boolean
- Uint8Array -> byte[]
- Array -> Array
- Callback function -> Callback
- Object(callback only) -> CallbackObject
- Object(data only) -> JSONObject
Callback
//Callback
callback.call(args0,args1,args2)
//CallbackObject
callbackObject.call("onSuccess",args0,args1,args2)
callbackObject.call("onFail",args0,args1,args2)
You need to release a callback if you don’t need it any more.
callback.release()
callbackObject.release()
Version Compatible
The following tow versions are compatible
- A.B.x
- A.B.y