A safe JsBridge framework!
rainbow://class:port/method?params
params is a json string.
resultData = {
status: {
code: 0,//0:Success,1:Failure
msg: 'request timeout'//Failure to display a message, success can be null
},
data: {}//resultData,can be null
};
javascript:RainbowBridge.onComplete('port','resultData');
public static void ***(WebView webView, JSONObject data, JsCallback callback) {
//...
JsCallback.invokeJsCallback(callback, true, result, null);
}
If the native method is time consuming operation.Such use:
public static void ***(WebView webView, JSONObject data, JsCallback callback) {
AsyncTaskExecutor.runOnAsyncThread(new Runnable() {
@Override
public void run() {
//IO、decode、sqlite...
JsCallback.invokeJsCallback(callback, true, result, null);
}
});
}