一、http适配
背景:API升级到28以后,不再支持明文的网络请求,只支持https请求。运行所报错误:java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security policy
解决方案:
1、//.在res目录下,新建xml目录,在xml目录下新建`network_security_config.xml`文件
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
2、在manifest的application下设置如下属性
android:networkSecurityConfig="@xml/network_security_config"