AndroidとH 5の相互調整
1608 ワード
and roid調H 5
H 5調android window.android.get Mobile() h 5はandroidの値を持つ window.android.Jump() h 5はAndroidの値をあげます
evaluateJavascript js
// H5 Web Javascript add() a b 。
web.evaluateJavascript("toggle()", new ValueCallback() {
//Javascript add() 。
@Override
public void onReceiveValue(String value) {
ToastUtils.showLong(value);
}
});
myWebView.loadUrl js
testResult js content js
String method = "javascript:testResult('" + content + "')";
myWebView.loadUrl(method);
// js get_android_base
webview.evaluateJavascript("javascript:get_android_base("aaa")", new ValueCallback() {
@Override
public void onReceiveValue(String value) {
// js
Log.v("Native",value);
}
});
H 5調android window.android.get Mobile() h 5はandroidの値を持つ window.android.Jump() h 5はAndroidの値をあげます
gameSquare.addJavascriptInterface(new Currency(), "android");
private class Currency {
@JavascriptInterface
public String getMobile() {
return "111111";
}
@JavascriptInterface
public void Jump(String a) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (a.equals("1")){
}else {
}
}
});
}
}