小编ALZ*_*ALZ的帖子

明文 HTTP 流量...不允许

我的程序从用户那里获取一个 URL,因此它可以向互联网上的任何网站发出请求。我试图让这成为可能,我查找了有关“Android HTTP Cleartext”错误的所有答案,并做了这个,但它仍然不允许我连接我的测试本地 PHP 服务器,我在这里缺少什么?

<uses-permission android:name="android.permission.INTERNET" />
...
<application
...
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="UnusedAttribute"
Run Code Online (Sandbox Code Playgroud)

我的安全配置:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">api.example.com</domain>
    </domain-config>
</network-security-config>
Run Code Online (Sandbox Code Playgroud)

谢谢!

android http cleartext

2
推荐指数
1
解决办法
5956
查看次数

标签 统计

android ×1

cleartext ×1

http ×1