gpt4 book ai didi

crosswalk-runtime - 如何在XWalkView中启用javascript?

转载 作者:行者123 更新时间:2023-12-02 12:57:15 27 4
gpt4 key购买 nike

此 URL 显示了如何使用: http://zhangwenli.com/blog/2014/08/25/crosswalk-calling-java-methods-with-javascript/

但是,getSettings() 函数现已删除。

现在如何启用 Javascript?

最佳答案

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();

关于crosswalk-runtime - 如何在XWalkView中启用javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29440153/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com