【问题标题】:How to load web content on turbolinks-android如何在 turbolinks-android 上加载网页内容
【发布时间】:2017-12-31 04:39:49
【问题描述】:

我有一个使用 Ruby on Rails 制作并启用了 Turbolinks 5 的网络应用程序,但目前,我需要制作一个实际由 Basecamp 设计的原生 Android 应用程序。

在他们的GitHub repository 上进行了逐步设置,我正在按照这些步骤进行操作,因为根据他们的教程,这里(谷歌)对turbolinks-android 的帮助不足,但我没有加载任何类似的内容

#=> If I use Basecamp URL
private static final String BASE_URL = "https://basecamp.com";

不改变任何东西总是显示空白屏幕

#=> My local project
private static final String BASE_URL = "http://localhost:3000";

同样不改变任何显示空白屏幕的东西

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <com.basecamp.turbolinks.TurbolinksView
    android:id="@+id/turbolinks_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</LinearLayout>

MainActivity.java

import com.basecamp.turbolinks.TurbolinksSession;
import com.basecamp.turbolinks.TurbolinksAdapter;
import com.basecamp.turbolinks.TurbolinksView;

所有的都和他们的文档一样

如果有帮助,不胜感激

谢谢

【问题讨论】:

    标签: java android ruby-on-rails turbolinks-5 turbolinks-android


    【解决方案1】:

    不确定您是否仍在寻找答案。 turbolinks-androidRails 5.2 Web 应用程序遇到了完全相同的问题。

    问题是由content_security_policy 引起的,它在最新的 Rails 版本中默认启用。我通过注释掉 config/initializers/content_security_policy.rb 文件中的内容来修复它。

    对于未来的问题也是一个很好的提示 - 使用adb logcat 命令与通过 USB 连接的设备。它会告诉你究竟是什么导致了错误。

    【讨论】:

      【解决方案2】:

      他们的示例项目不再工作。可能是因为它的deprecated。但是他们在他们的应用程序中使用它,所以它还没有死。示例项目的第一个问题是它需要使用 2 个额外的库:

      implementation 'com.basecamp:turbolinks:1.0.9' // Turbolinks
      implementation 'com.google.code.gson:gson:2.8.2' // Important addition 1
      implementation 'org.apache.commons:commons-lang3:3.1' // Important addition 2
      

      此外,没有 SSL 的 HTTP 也无法正常工作,因此您需要使用 ngrok 之类的东西来通过 HTTPS 建立连接。

      你可以在Github查看我的工作示例

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-08-27
        • 1970-01-01
        • 2012-04-15
        • 1970-01-01
        • 1970-01-01
        • 2012-10-07
        • 1970-01-01
        相关资源
        最近更新 更多