- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将我的代码移植到 android 6.0。由于 apache 类已在 API 23 中弃用并删除,因此我无法找到与之前的代码完全匹配的代码来建立 HTTPS 连接。以下是我的代码
try {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https",new CustomSSLSocketFactory(), 443));// new CustomSSLSocketFactory().newSslSocketFactory(context.getResources()), 443));
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 120000);
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParameters, schemeRegistry);
httpClient = new DefaultHttpClient(cm, httpParameters);
setHttpClient(httpClient);
AbstractMediator.setServerTime(System.currentTimeMillis());
httpResponse = httpClient.execute(request);
serviceResponseObject.setResponseCode(httpResponse.getStatusLine().getStatusCode());
serviceResponseObject.setMessage(httpResponse.getStatusLine().getReasonPhrase());
serviceResponseObject.setAllHeader(httpResponse.getAllHeaders());
Header[] header = httpResponse.getAllHeaders();
}catch (UnknownHostException e){
Utility.printStackTrace(e);
serviceResponseObject.setResponseBody("");
return responseWithErrorCode(NETWORK_ERROR_CODE101, serviceResponseObject);
} catch (IOException e) {
Utility.printStackTrace(e);
return responseWithErrorCode(NETWORK_ERROR_CODE100, serviceResponseObject);
} catch (Exception e) {
Utility.printStackTrace(e);
return responseWithErrorCode(NETWORK_ERROR_CODE100, serviceResponseObject);
}
我已阅读此链接 Deprecated: org.apache.http.conn.scheme.scheme is deprecated 。它确实提到了方案类的新构造函数,但没有提到其余的方法。我的应用程序最低 API 级别是 14,如果有任何替代方法确实尊重它,我会很高兴。
我读过这篇文章'org.apache.http.HttpEntity' is deprecated. How to solve this error in android studio?其中讨论了使用 apache 旧版以及有关 Marek Sebera 的新 Android Apache HttpClient 包的其他解决方案,但这并不能满足我的目的。
我无法使用 Volley、Retrofit、OKHttp 等库,因为我有 Soap XML 格式的 Web 服务
我想完全从 apache 迁移出去。我关心的是知道 HttpsUrlConnection 类中的所有方法都可以用于替换。如果我能得到一个与此相关的代码,该代码完全按照我上面所做的操作,但使用新的 API 方法,我将不胜感激。我开始了解Registry、PoolingHttpClientConnectionManager等类,但我不明白如何使用它们来获得上述结果
最佳答案
据 Google 称,在 Android 6.0 中,他们取消了对 Apache HTTP 客户端的支持。从 Android 9 开始,该库已从 bootclasspath 中删除,并且默认情况下不可用于应用。
因此,如果您仍然希望将其提供给您的应用程序,Google 也提供了解决方案。
在 AndroidManifest.xml
文件的应用程序内使用以下标记
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
有关迁移过程的更多详细信息,请参阅 Android 文档。 https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p
关于java - 替换已弃用的 org.apache.http.conn.scheme.SchemeRegistry、ThreadSafeClientConnManager 类等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37562189/
所以我正在尝试实现类似 Imgur 的功能,非网站成员(member)的用户可以上传并继续编辑该上传内容(直到 cookie 被重置)。 当查看conn结构时,有3个地方出现了用户的cookie。 c
我已经用服务器和客户端完成了一个应用程序,以使用套接字 TCP 发送信息 问题是,如果函数 zfs.ReceiveSnapshot(在服务器端)没有返回错误(err == nil),conn.Writ
经常开发asp但对于细致的说法,真实不太清楚,这里简单的介绍下。 一般情况下 读取数据都是用rs.open sql,conn,1,1 修改数据:rs.open sql,conn,1,3 删除
后 iex -S mix phx.server 我想在 iex 终端做一些快速测试,但有些函数需要 struct %Plug.Conn{} 作为参数,例如我想得到表达式的结果: MyAppWeb.Ro
我正在尝试报告一些代码增强,但是,我不太确定这个项目叫什么。基本上,它不是执行 conn == null,而是执行 null == conn 以提高可读性。 之前: if (conn
这个问题在这里已经有了答案: Is this casting in golang? (1 个回答) What does "i.(string)" actually mean in golang syn
我的代码有点复杂,但简单来说,它有多个 go 例程,所有都调用不同的 TCP 服务器,并在流中出现可读消息时在 for 循环中读取输入。到目前为止,一切都很好。现在有另一个 go 例程来管理之前的一堆
我创建了一个 DBManager 类,如下所示 public class DBManager { public static String DRIVER = "oracle.jdbc.dr
在此处查看 Async/Await 示例: https://github.com/sidorares/node-mysql2/blob/master/documentation/Promise-Wra
在我的一个 Controller 中,我有以下代码(摘录): case HTTPoison.get("https://*****.zendesk.com/api/v2/users/search.jso
conn.execute('some string') 和 SQLAlchemy 中的 conn.execute(text('some string')) 有什么区别? 上面conn是通过conn =
我正在尝试使用btmgmt rust库读取连接的BLE设备的RSSI值,但总是得到127。。我确信该设备已连接,并已解决服务问题,下面是BluToothctl输出:。我尝试使用CLI呼叫btmgmt,
我正在使用MySQL Workbench 。如果我打开一个到 MySQL 的连接(在 Visual Basic 中),它将显示连接已打开。如果我关闭连接(在 MySQL Workbench 中),它会
我在 maven 项目中运行 selenium 测试。这个项目是 GWT Web 应用程序。在 pom.xml 中有 GWT 依赖项,hibernate 依赖项。我在测试包中创建了一个新类来运行 se
我尝试使用 HttpComponentsMessageSender 在 Spring WebServiceTemplate 中设置 ConnectionTimeout 和 ReadTimeout。但是
我刚刚将我的代码从 mysql 更改为 mysqli 并且最好是: 如何避免在每个查询或某些 mysqli 函数中使用 $conn? $conn = mysqli_connect("localhost
执行一条sql查询后,我想访问返回事件的id(主键),以便我可以在另一个sql中使用它。我尝试使用 result.insertId 访问它,但返回的事件对象似乎为 null。我什至控制台记录了 res
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界. 这篇CFSDN的博客文章Asp Conn.execute的参数与返回值总结由作者收集整理,如果你
我正在尝试使用GO与服务进行简单的UNIX套接字通信。为了测试,我创建了一个socket,如下所示: $ nc -vlU /tmp/sock Bound on /tmp/sock Listening
我很难对失败的测试进行故障排除,其中 conn.assigns 都是同一测试语句的一部分,但在测试的两行之间被清空。 我正在阅读“Programming Phoenix”,并重新编写代码以使其与 Ph
我是一名优秀的程序员,十分优秀!