The android 9.0 can not access the http request network

Recently proposed making a video player, a device found on 9.0, can not play video resources http:

http://chuangfen.oss-cn-hangzhou.aliyuncs.com/public/attachment/201805/100651/201805181532123423.mp4

Solution:
step1:
Statement in Application node of the manifest file a android: networkSecurityConfig property, and points to a new network profile network_security_config

// AndroidManifest.xml

    <application
     	...
        android:networkSecurityConfig="@xml/network_security_config"
      	...
     	>
    </application>

step2:
In the res folder named New "xml" folder, and create a network profile network_security_config in the "xml" folder, to allow access to the domain name to the statement.

//network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">chuangfen.oss-cn-hangzhou.aliyuncs.com</domain>
    </domain-config>
</network-security-config>

Conclusion: The
solution feasible

Published 98 original articles · won praise 6 · views 20000 +

Guess you like

Origin blog.csdn.net/dirksmaller/article/details/103222920