This is because starting with Android P, any network traffic between your app and insecure destinations must be explicitly whitelisted. See Protecting users with TLS by default in Android P.
In your code, you're making a request to:
http://hellapunk.com/listallshows.php?id=2018
The http://
shows that the site is not secure. If you dig deeper into your LogCat you'll likely find a message such as:
com.android.volley.NoConnectionError: java.io.IOException: Cleartext HTTP traffic to hellapunk.com not permitted
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:177)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
Caused by: java.io.IOException: Cleartext HTTP traffic to hellapunk.com not permitted
at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:115)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:458)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)
at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:99)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)?
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)?
Attempting it myself, it doesn't appear that the site supports https
connections, so in order to reach this particular server from your application, you would need to whitelist the hellapunk.com
domain manually.
In your resources directory, define an XML document for your network security configuration (e.g. res/xml/network_security_config.xml
):
network_security_config.xml:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">hellapunk.com</domain>
</domain-config>
</network-security-config>
Then, in your AndroidManifest.xml
for your application, in the <application>
tag, add the attribute:
<application
android:networkSecurityConfig="@xml/network_security_config"
You should then be allowed to make insecure requests to any domain specified within that file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…