问题标签 [android-async-http]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3213 浏览

android - Android Async Http 客户端 - 带有 InputStream 的 POST 请求

我正在尝试使用Android Async Http库作为我的客户端向我的 REST Web 服务发送 POST 请求。

对于我的网络服务,我使用的是 RESTlet 框架。

这是我的网络服务上的处理程序方法:

这是我在 Vcard 类中的 echoVcard 方法:

这是我的 Android Async Http 客户端:

这是我的堆栈跟踪:

谁能指出我收到的 400 Bad Request 响应的错误在哪里?

0 投票
1 回答
2255 浏览

android - onSuccess - 异步 Http 客户端

我正在使用Android Asynchronous Http Client。我的代码看起来像这样并且工作正常。

我实现了一个静态 HTTP Client。我的服务器返回这个 JSON 数据{"message":"success"}。我不想将其视为字符串并将其转换回 JSON。但是当我把它改成public void onSuccess(JSONObject answer)eclipse 告诉我

new AsyncHttpResponseHandler(){} 类型的 onSuccess(JSONObject) 方法必须覆盖或实现超类型方法

0 投票
1 回答
2568 浏览

android - 多个获取请求无法正常工作

我正在使用以下函数,但有 AsyncTask Exception 虽然我得到了有效的响应,为什么会这样。

例外情况如下:

由于多个 Get Request 会造成内存泄漏并中断 AsyncThread

内存泄漏如下

0 投票
1 回答
1607 浏览

php - 使用 LoopJ AndroidAsyncHttp 检索值

我刚刚开始使用 LoopJ AndroidAsyncHttp 库及其出色的数据上传功能。

但是,我现在正尝试使用 get 请求获得响应,但我似乎无法理解为什么我的 onSuccess 和 onFailure 方法都没有被调用。我浏览了这里的问题,似乎找不到解决 onSuccess 方法的新实现的问题。有人可以帮忙吗?

在 ButtonClick 上调用的方法:

这是我的 php 代码(在 chrome 上使用 Postman Client 可以正常工作,我已经在 EDIT2 中发布了输出):

我也使用其他 ResponseHandlers 尝试过同样的事情,但这也不起作用。真心希望得到解答!

编辑:添加有效且在同一活动中完美运行的代码。这是一个帖子请求:

EDIT2:从 php 页面返回给 POSTMAN 客户端的响应:

[{"id":"7","path":"uploads/speed.png"},{"id":"8","path":"uploads/Untitled.png"},{"id": "9","path":"uploads/Untitled.png"},{"id":"10","path":"uploadsspeed_2.png"},{"id":"11","path": “上传/speed_3.png”}]

0 投票
1 回答
1383 浏览

android - 使用 AsyncHttpResponseHandler 进行多次调用

我正在开发一个应用程序,该应用程序将来自网站的 json 数据列表加载到列表中。在该列表中,每个项目都有一个与之关联的图像。MediaAdapter 与每一行一起工作,并为每个图像调用异步加载。

问题来的不规律。目前列表中有 3 个项目(和 3 个图像)。有时我会收到 1 张图片,有时会收到 2 张。我很少收到所有 3 张图片。我已经设置了日志记录,并在不破解打开的 android-async-http 的情况下跟踪了我能做的事情。

在下面的日志记录中,请注意,为 joe_thumb__804587.jpg 调用了 onStart,但我从未收到异常或对该请求的任何进一步更新。

这是一些代码和一些日志记录。

媒体适配器(注意:MediaLoader.fetchBinary 是传递给 BinaryNetworkClass):

二进制网络类:

这是一些日志记录:

0 投票
0 回答
102 浏览

php - Android - AsyncHttp no response - BCrypt

i'm trying to register a user (from an Android app) to my server.

For my website, it works well and i receive my JSON response.

Into my app, when i send the request if all the data are good and the person is registered i do not get any response.

It's the same function ...

I found the line where, after this line i do not get any response on my app.

It's the one when i call my model to save the guy in my database. To encrypt his password, i use BCrypt with a cost of 13.

I thought it would take a long time and maybe the timeout of AsyncHttp was too small but it's 10s and on the website the user does not wait more than 1s when he get registered.


I didn't put any code because it's working perfectly on the website, and on the app i get all the error messages if there are any. It's just when i use BCrypt on the server, my app doesn't get any response ...

Any idea why ? I'd really appreciate any help. Thanks in advance ! :)


EDIT : Here's some code if that can help

creer_inscrit function (to register the new guy) :

If i call the function from a browser, it works, if i call the function from my android app, i do not get any answer from the server when it reachs the line

I can get the errors before like for example nickname_already_exists.

Thanks

0 投票
1 回答
2932 浏览

android - LoopJ AndroidAsyncHttp 和持久 cookie 存储

在我的服务中,我运行以下代码:

当我检查我的网络服务器日志时,我可以看到请求标头中存在 cookie。
但这些饼干是旧饼干。

我还从一个 Activity 运行这个 AndroidAsyncHttp 代码。发送相同的旧 cookie。

但是当我在我的 WebView 中打印出当前的 cookie 时,我会看到新的 cookie。

如何使用 AndroidAsyncHttp 发送 WebView 的 cookie?

0 投票
4 回答
379 浏览

android - Async-http 经常挂起。

当我启动异步请求时,我启动了一个 ProgressDialog,并且在看似随机的情况下,对话不会关闭(代码不会触发 onSuccess 或 onFailure)。我处理来自服务器的两种可能的成功响应(其中一个是错误)并且我有一个失败块,所以理论上 ProgressDialog 应该总是关闭。有人可以告诉我错过了什么活动吗?还是有更好的结构?

我的代码结构:

  1. 我有一个处理所有网络的网关类
  2. 调用调用处理对话框的 .show() 和 .dismiss() 事件

网关:

适配器:

0 投票
8 回答
2711 浏览

android - 开发一个负责所有网络任务的辅助网络类是一种好习惯吗?

我创建了以下类:

这门课还没有完成,我还需要在这里添加另外 10 个我在应用程序周围执行的其他网络调用。

要运行其中一个网络任务,我运行这一行,例如:

Event当任务完成时,我使用Square事件工具触发Bus向活动/片段布局提交所需的视觉更改。

问题:我的老板声称这是一种不好的做法,当我完成这门课时会变得一团糟。此外,他声称这个类应该是一个愚蠢的类,他所知道的只是配置AsyncHttpClient对象并返回它,这样我就可以使用它并在相关的Activity. 基本上他说 https 调用本身应该位于 Activity 类中。我更喜欢这种方式,并认为它使我的活动更清晰,更易于阅读。另一方面,他说这种方式更难调试,并且这个类结合了控制器和视图功能的一部分,这是它不应该做的。

那么谁是对的呢?创建这样的课程真的是一种不好的做法吗?

0 投票
1 回答
402 浏览

android - LoopJ AndroidAsyncHttp – 更多任务

我想在一个 Activity 中使用 AsyncHttpClient 来完成更多任务(我需要通过 REST 从不同的 URL 获取和更新数据)。但我不确定如何处理这个问题。我的想法如下:

但我不确定我是否可以这样做。感谢您的任何建议。