android 9.0 http无法访问问题

时间:2019-07-02 16:19:52   收藏:0   阅读:167

在res/xml下新建network-security-config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

修改AndroidManifest.xml文件 在application标签上添加 android:networkSecurityConfig="@xml/network_security_config"

<application
        android:name=".conf.MyApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_logo"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_logo_round"
        android:supportsRtl="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:theme="@style/AppTheme">

然后就可以使用了(本地捣鼓半天自签名https证书没成功,先这么用着)

原文:https://www.cnblogs.com/rchao/p/11121307.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!