此网址显示如何使用: http://zhangwenli.com/blog/2014/08/25/crosswalk-calling-java-methods-with-javascript/
但是,现在删除了getSettings()函数。
现在如何启用Javascript?
答案 0 :(得分:10)
public class MyActivity extends Activity {
private XWalkView xWalkWebView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity_xml);
xWalkWebView = (XWalkView)findViewById(R.id.xwalkView);
xWalkWebView.addJavascriptInterface(new WebAppInterface(), "Android");
xWalkWebView.load(url_your_want_to_load,null);
}
public class WebAppInterface {
@org.xwalk.core.JavascriptInterface
public void callFunction(){
// Do your Android Stuff here
}
}
}
现在在页面中调用函数:
Android.callFunction();