【问题标题】:Android Webview support TLS 1.2 pre KitkatAndroid Webview 支持 TLS 1.2 pre Kitkat
【发布时间】:2016-02-11 03:47:09
【问题描述】:

是否有可能在 Kitkat 之前的 WebView 中支持 TLS 1.2?

我发现了这个 SO 问题,但我想知道现在是否有人知道它的答案:

Enabling specific SSL protocols with Android WebViewClient

【问题讨论】:

  • 你好,我也遇到了同样的问题,你连接成功了吗?

标签: android ssl android-webview


【解决方案1】:

我已经尝试了所有可用的解决方案,但不适用于 4.3 以下的 webview。我找到的解决方案是用 CrossWalk 替换 WebView。缺点是将您的 apk 文件大小增加 40mb,除非您通过拆分 arm 和 x86 来优化它。

在 build.gradle 中

repositories {
    maven {
        url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
    }
}

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.1' //optional, in case you have compile issue.
    }
}

implementation 'org.xwalk:xwalk_core_library:19.49.514.5' //latest available library for min 14 API

布局

 <org.xwalk.core.XWalkView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/web_view"/>

代码

XWalkView webview = (XWalkView) findViewById(R.id.web_view);
webview.load(url,null);

默认启用 Javascript 和 DOM 存储。两行代码即可完成基本工作。

【讨论】:

    猜你喜欢
    • 2018-08-23
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-18
    • 2016-09-12
    • 2020-04-10
    • 2016-06-24
    相关资源
    最近更新 更多