I am trying to make a http request to a device which creates its own wifi hotspot and which allows only http requests. With android 8 and lower http request are successful but with android 9 they are failing. Though with google pixel 2 it seems to be working, which uses android 9.
I have tried to enable android:usesCleartextTraffic="true" in AndroidManifest.xml .
I set networkSecurityConfig like suggested in the solution found here How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?
AndroidManifestXml
<application
android:networkSecurityConfig="@xml/network_security_config"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask"
android:usesCleartextTraffic="true">
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>