为什么 Android 10 HTTPUrlConnection 会失败? 9 工作正常

Why does Android 10 HTTPUrlConnection fail? Worked fine on 9

使用此代码

  URL url = new URL(data.replaceAll(" ", "%20"));
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setReadTimeout(12000);
        urlConnection.setConnectTimeout(12000);
        int xy = urlConnection.getResponseCode();

我遇到了这个异常:

data = "http://myrpd.us/api/staff1?lang=eng"
urlConnection = {HttpURLConnectionImpl@11410}    "com.android.okhttp.internal.huc.HttpURLConnectionImpl:http://myrpd.us/api/staff1?lang=eng"
e = {UnknownHostException@11411} "java.net.UnknownHostException: Unable to resolve host "myrpd.us": No address associated with hostname"

URL 在 9 和浏览器中工作正常。 我已经阅读了 10 的所有新隐私信息。我在清单中有这个:

android:usesCleartextTraffic="true"

没有互联网连接时也可能出现此错误

java.net.UnknownHostException: Unable to resolve host 

你能检查你的 Android 10 设备上的互联网连接吗?