android - Android 10 中的服务器连接问题

标签 android connection android-10.0 httpsurlconnection

我们正在尝试与“HttpsURLConnection”对象进行服务器通信,我们已将请求对象的“connection”属性设置为“关闭”[setRequestProperty("Connection", "关闭")]。上述设置在所有设备的 Android 9 操作系统中都运行良好,但在某些使用 Android 10 操作系统的设备(例如:配备 Android 10 的三星 A70)中,我们遇到了 "java.net.ConnectException”。当我们删除连接属性后,服务器通信就建立起来并解决了问题。我需要您的支持来了解 Android 10 操作系统中行为发生变化的根本原因以及删除连接对象是否会产生任何影响

url = new URL(reqURL);
httpsConnection = url.openConnection();
httpsConnection.setRequestMethod("POST");
httpsConnection.setRequestProperty("Content-Language", "en");
httpsConnection.setRequestProperty("Connection", "close");
httpsConnection.setRequestProperty("Content-Type","application/text");
OutputStream os = httpsConnection.getOutputStream();
os.write(cvmesgToServer.getBytes()) httpsConnection.connect();

最佳答案

关于android - Android 10 中的服务器连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61187285/

相关文章:

node.js - node-mysql无法处理多个查询?

c++ - Visual C++ 2010 连接 MySQL

android - ListViewAutoScrollHelper.canTargetScrollVertically处的NullPointerException(ListViewAutoScrollHelper.java:73)

java - Android SQLite select语句奇怪的行为

android - cursor.setNotificationUri() 是做什么用的?

c# - ADO.NET:检查数据库服务器是否可访问的更快方法?

android - 如何直接从 APK 运行嵌入式 DEX 代码

android - Gradle / Jenkins : Create a gradle file to direct to sub projects

android - Resources.getIdentifier 替代方案

android - 在通知区域中监听 "Dark Theme"切换并收到更改通知