In my case main reason of this problem was , I have used http:// rest call to get the data from backend.
But Android has safety restrictions which force the application to use https:// instead of http://.
But some of the URLs will work only with http:// and will not work with https://
e.g :
http://dallas-restaurants.33gfuuywva.us-east-2.elasticbeanstalk.com/restaurants/
This URL will not work if we give like this with https://
https://dallas-restaurants.33gfuuywva.us-east-2.elasticbeanstalk.com/restaurants/
In these situations we need to forcefully use the http:// urls in our application like below
AndroidManifest.xml:
But Android has safety restrictions which force the application to use https:// instead of http://.
But some of the URLs will work only with http:// and will not work with https://
e.g :
http://dallas-restaurants.33gfuuywva.us-east-2.elasticbeanstalk.com/restaurants/
This URL will not work if we give like this with https://
https://dallas-restaurants.33gfuuywva.us-east-2.elasticbeanstalk.com/restaurants/
In these situations we need to forcefully use the http:// urls in our application like below
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest android:targetSandboxVersion="1">
<uses-permission android:name="android.permission.INTERNET" />
<application ....... android:networkSecurityConfig="@xml/network_security_config"> <activity android:name="....Activity">
</manifest>
res/layout/xml/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>Then this will allow the application to use http://

No comments:
Post a Comment