【问题标题】:Can't get appView after Update to cordova 5.1 from 3.4从 3.4 更新到 cordova 5.1 后无法获取 appView
【发布时间】:2015-07-21 20:18:52
【问题描述】:

我最近将我的应用更新到了 cordova 5.1,但我无法从 JS 发出 Web 请求。

编译过程中唯一的问题是 在我的类的 onCreate 函数中扩展了 CordovaActivity

我曾经这样做过

super.appView.getSettings().setAppCacheEnabled(false)

现在它说投射它...我试过了 (WebView)super.appView 但应用程序因非法演员而崩溃

我读过This link 并尝试做同样的事情 (WebView)super.appView.getEngine().getView() 但我仍然无法发出网络请求....在 iOS/Desktop chrome 上它工作正常,所以 JS 代码没有任何问题

【问题讨论】:

  • 你找到解决办法了吗?
  • @ntaj 我发现了两件事,一是添加了我没有添加的白名单插件,所以我无法发出网络请求……二是 (WebView)super.appView.getEngine()。 getView().getSettings() 是正确的解决方案

标签: android ios cordova


【解决方案1】:

您必须从 Cordova 引擎获取 WebView

WebView webView = (WebView) appView.getEngine().getView();

【讨论】:

    猜你喜欢
    • 2015-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多