android 9 無法使用 http

1 篇文章 / 0 new
author
android 9 無法使用 http
android 安全因素使用 http 連結會發出例外 java.io.IOException: Cleartext HTTP traffic to not permitted
http 許可處理方式
1. 在專案建立 res/xml/network_security_config.xml 檔, 內容如下
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>
2. 在 AndroidManifest.xml 加入
<application
        android:networkSecurityConfig="@xml/network_security_config"
Free Web Hosting