使用lib类库xUtils-2.6.10.jar作为数据请求的框架,在android的5.0版会有兼容问题,取不到GET请求的数据。
但是POST没有问题,难取到数据。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public static ResponseContext invokeGet(String url, List<NameValuePair> headers) { ResponseContext result = new ResponseContext(); try { RequestParams requestParams = new RequestParams(); if (headers != null && headers.size() > 0 ) { requestParams.addBodyParameter(headers); } result = invokeRequest(url, requestParams, HttpRequest.HttpMethod.GET); } catch (Exception e) { String messageString = e.getMessage(); result.setMessage(messageString); Log.e(TAG, messageString); } Log.d(TAG, "over" ); return result; } |
调试发现,返回的结果result是null值。
解决办法:
升级类库:xUtils-2.6.10.jar--->xUtils-2.6.14.jar
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步