I\'m trying to print a list of values in ListView
from a webpage. I have the two permission
The message you're getting isn't an error; it's just letting you know that you're not using a Network Security Configuration. If you want to add one, take a look at this page on the Android Developers website: https://developer.android.com/training/articles/security-config.html.
This is my local context solution...
I have a Docker/Lando instance providing me an API from a Lumen Restful app, local domains are not working ("https://localhost:32769", "http://localhost:32770", "http://wxyz.lndo.site", "https://wxyz.lndo.site"), however, when I check the network IP using "ifconfig" in the terminal I could access using that IP
$ ifconfig
You must add a new parameter to your AndroidManifest.xml
android:networkSecurityConfig="@xml/network_security_config"
I use this network_security_config.xml file for local debugging
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<debug-overrides>
<trust-anchors>
<certificates src="user" overridePins="true"/>
</trust-anchors>
</debug-overrides>
</network-security-config>
I use user-permissions as well
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I had the same issue and after debugging it further, I found it a thread issue. I changed onCreate
method as below and it works fine. No playing Network Security Configuration file.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT > 9)
{
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
....
....
}
Hope it helps.
Add this:
android:usesCleartextTraffic="true"
to your manifest application
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme"
>
hope it helps