工作灯应用在Android里面的片段 [英] Worklight App inside an Android Fragment

查看:135
本文介绍了工作灯应用在Android里面的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来承载Android的碎片?

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

我试图用一个片段onCreateView内WLWebView

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;

但它会导致超时错误,即使我能看到的HTML。这可能是工作灯的连接失败,因为我们使用的是 WL.Client.connect()。该错误并不指定哪些URL超时。

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.

我不相信WLDroidGap类(作为主要活动)增加了一大堆群众演员到WLWebView使事情工作,但我没有访问源代码,看看到底是什么。

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.

这可能吗?

推荐答案

创建CordovaWebViewClient()和CordovaChromeClient()实例,并与网页视图中使用它们。检查了两次的init()的<一个方法href=\"https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaActivity.java\" rel=\"nofollow\">https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaActivity.java

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

这篇关于工作灯应用在Android里面的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆