-1

I am making an app for my customer. The app calls JSON CURL Post to show some values in the dropdown. The code works fine in Oreo, but on Android PIE phones, it cannot pull data. I changed client services with my Service but got the same result. I shifted my services from HTTP to https, then it worked fine in Android PIE phones. But I cannot tell my client to provide me https responses. I know there must be a way to access the HTTP JSON response from Android PIE. Please help.

Ranajoy Roy
  • 35
  • 1
  • 9

1 Answers1

1

I had the same problem with Android 9, it was confused but with a little research, I found new features about the new Android version (PIE) related with the security transmit data, here you'll found the solution:

SOLUTION

According to Network security configuration

Option 1 -

Create file res/xml/network_security_config.xml - `

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">Your URL(ex: 127.0.0.1)</domain>
    </domain-config>
</network-security-config>

`

On your AndroidManifest.xml -

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:networkSecurityConfig="@xml/network_security_config"
        ...>
        ...
    </application>
</manifest>

Option 2 -

android:usesCleartextTraffic Doc

On your AndroidManifest.xml -

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

Its works perfectly for me, I used the Option 2 :)

I hope I've helped :)

Marco Chavez
  • 365
  • 2
  • 7