如何在Android(9)Pie中允许所有网络连接类型HTTP和HTTPS? [英] How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

查看:774
本文介绍了如何在Android(9)Pie中允许所有网络连接类型HTTP和HTTPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Android 9 Pie开始,没有加密的请求永远不会有效。默认情况下,系统会默认使用TLS。您可以在此处阅读此功能因此,如果您只通过HTTPS发出请求,那么您就是安全的。但是那些通过不同网站提出请求的应用程序呢,例如类似浏览器的应用程序。

From Android 9 Pie now, requests without encryption will never work. And by default, the System will expect you to use TLS by default.You can read this feature here So if you only make requests via HTTPS you are safe. But what about apps that make requests through different sites, for instance, browser-like apps.

如何在Android 9中启用对所有类型的连接HTTP和HTTPS的请求Pie?

How can I enable requests to all types of connections HTTP and HTTPS in Android 9 Pie?

推荐答案

要在Android 9 Pie中执行此操作,您必须设置 networkSecurityConfig 在你的Manifest 应用程序这样的标签中:

To do this in Android 9 Pie you will have to set a networkSecurityConfig in your Manifest application tag like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config">




    </application>
</manifest>

然后在您的 xml 文件夹中,您现在拥有创建一个名为 network_security_config 的文件,就像你在Manifest中命名它一样,从那里你的文件内容应该是这样的,以启用所有没有加密的请求: / p>

Then in your xml folder you now have to create a file named network_security_config just like the way you have named it in the Manifest and from there the content of your file should be like this to enable all requests without encryptions:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

从那里你很高兴。现在,您的应用程序将请求所有类型的连接。有关其他信息,请在此处阅读

From there you are good to go. Now your app will make requests for all types of connections. For additional information read here.

这篇关于如何在Android(9)Pie中允许所有网络连接类型HTTP和HTTPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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