AndroidとJsが交互に戻り値を取得します.
961 ワード
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//sdk>19
String script = ("javascript:getContent()");
webView.evaluateJavascript(script, new ValueCallback() {
@Override
public void onReceiveValue(String responseJson) {
// js ,
Log.i("aa", " responseJson" + responseJson);
}
});
} else {//sdk<19 , prompt
String[] paths = moduleUrl.split("/", 3);
promptMap.put(paths[2], paths);
webView.loadUrl("javascript:mandaobridge.getParams('!" + paths[2] + "')");
LogUtils.d("Prompt :" + "mandaobridge.getParams('!" + paths[2] + "')");
}
finish();