Worklight App inside an Android Fragment

。_饼干妹妹 提交于 2019-12-11 19:38:22

问题


Is there a way to host a Worklight app inside an Android Fragment?

I have attempted to use the WLWebView inside a Fragments onCreateView

WLWebView webView = new WLWebView(getActivity());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///path_to_app.html_file", 60000);
return webView;

But it results in a timeout error even though I can see the HTML. It could be the connection to Worklight failing as we are using WL.Client.connect(). The error doesn't specify which URL timed out.

I do believe that the WLDroidGap class (which is used as the primary activity) adds a whole lot of extras to the WLWebView to make things work but I don't have access to the source to see what exactly.

The requirement we have is that we want to have a Native app hosting a Worklight app.

Is this possible?


回答1:


Create CordovaWebViewClient() and CordovaChromeClient() instances and use them with your webView. Check out two init() methods of https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaActivity.java

webView.setWebViewClient(webViewClient);
webView.setWebChromeClient(webChromeClient);
webViewClient.setWebView(webView);
webChromeClient.setWebView(webView);



回答2:


What is the rationale behind having a native app hosting a Worklight Hybrid app?

The current alternatives are:

  1. Native app that uses the Worklight Native API for Android
  2. Hybrid app that uses WL.NativePage.show to display native screens

More about this in the Getting Started training modules, chapters 6 and 7.



来源:https://stackoverflow.com/questions/17646059/worklight-app-inside-an-android-fragment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!