javaandroidweb-servicesconnectionxiaomi

Xiaomi does not connect ws, other mobile phones yes


i have a problem in the APP im developing with my Xiaomi Mi 9 SE that don´t have with my other (older) phones like BQ M5 or some Samsung.

My APP connects to a Web Service to get some information. I have 3 enviroments for this Web Service: Test (in a PC in local LAN), preproduction and production.

Test: "http://10.60.8.223:8080/ws/webservice.wsdl"; (Xiaomi dont connect, others yes)

PRE: "https://ws-pre.myaplication.com/ws/webservice.wsdl"; (All connect correct)

PRO: "https://ws-pro.myaplication.com/ws/webservice.wsdl"; (All connect correct)

With any other mobile phones I connect to the 3 enviroments, but with the Xiaomi i cannot connect to the TEST url where I am debugging the web service.

Do you know what is happening? What can I try? Maybe Xiaomi blocks http conection but admits https?

Thank you so much in advance. Adrián.


Solution

  • I have solved it:

    Create an xml file called network_security_config.xml in RES folder.

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
        <base-config cleartextTrafficPermitted="true">
            <trust-anchors>
                <certificates src="system" />
            </trust-anchors>
        </base-config>
    </network-security-config>
    

    in Android Manifest, inside application tag:

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