CrosswalkNative
CrosswalkNative copied to clipboard
addJavaScriptInterface problem
hi mr ks32
when i use “addJavaScriptInterface” add a interface for my js code then i used the interface like this “window.Android.funtionName” the will tell me “Uncaught TypeError: window.Android.funtionName is not a function”
@SuppressLint({"SetJavaScriptEnabled"})
private void initWebView(){
XWalkSettings webSettings = this.webView.getSettings();
webSettings.setLoadsImagesAutomatically(true);
webSettings.setSupportSpatialNavigation(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(false);
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webSettings.setDomStorageEnabled(true);
XWalkPreferences.setValue("remote-debugging", true);
webSettings.setAllowFileAccess(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
webSettings.setAllowContentAccess(true);
webSettings.setAppCacheEnabled(true);
webSettings.setFullscreenSupported(true);
this.uiClient=new XwalkClientEXT(this,this.webView);
this.webView.setResourceClient(new XWalkResourceClient(){
@Override
public void onLoadFinished(XWalkView view, String url) {
super.onLoadFinished(view, url);
setImmersiveMode();
}
});
this.webView.setUIClient(this.uiClient);
this.webView.clearCache(true);
this.webView.requestFocus(130);
this.webView.addJavascriptInterface(new JavaScriptInterface(this),"Android");
CookieManager.getInstance().setAcceptCookie(true);
CookieManager.setAcceptFileSchemeCookies(true);
((FrameLayout)findViewById(R.id.webview)).addView(this.webView);
}
@JavascriptInterface
public String io_sb3FileExists(String file) { return "";}
if("true"==window.Android.io_sb3FileExists(fileName)){}
hi,Have you solved this problem?