问题标签 [retrofit2]
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.
android - 如何知道 Retrofit 调用何时结束
有没有办法知道我的改造电话何时完成它的职责?我想知道何时收到所有数据,以便代码可以继续进行,例如开始另一个活动或使用第一次调用中的数据进行第二次?
Ps.:我正在使用异步请求(.enqueue)。
编辑:
file - Android:如何从图库中的图像 Uri 获取真实文件路径?
从图库中选择图像后,我想用retrofit2 上传它。
https://futurestud.io/blog/retrofit-2-how-to-upload-files-to-server
为此,我必须获取真实的文件路径。
allImgUris.get(0)给了我:
allImgUris.get(0).getPath()给了我:
我需要将真实文件路径传递给:
我发现了很多关于处理上下文和游标的函数的所谓“好”答案,但它们都不起作用。
知道如何解决这个问题吗?
看起来很微不足道,但结果却浪费了数小时的研究时间。
任何帮助将不胜感激!
不工作:
给出:
也不工作:
返回空
android - 如何使用 Retrofit 在 RxJava 中管理结果
我有一个使用 RxJava 的改造请求 API 调用。一切正常。
我如何优化这段代码。我是 RxJava 的新手。我将不胜感激一个小的示例代码或链接。谢谢。
java - How to make a POST request using retrofit 2?
I was only able to run the hello world example (GithubService) from the docs.
The problem is when I run my code, I get the following Error, inside of onFailure()
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
My API takes POST params value, so no need to encode them as JSON, but it does return the response in JSON.
For the response I got ApiResponse class that I generated using tools.
My interface:
Here is how I use the service:
android - Why should ThreadPoolExecutor be used with Retrofit?
I saw android's ThreadPoolExecutor implementation with Retrofit somewhere. I am confused what is a logical need of using this executor with retrofit even if retrofit already provides us mechanism of asynchronous api calls, which will be run in different background threads without affecting other api calls?
java - Retrofit 2.0.0-beta ClassNotFoundException: okhttp3 如何解决这个问题以检索轨道?- 使用 Soundcloud API
我一直在做这个教程。
但我似乎无法让应用程序运行。在尝试修复错误数小时后,我在我的 MainActivity.Java 中将其精确定位到了这一行SCService scService = SoundCloud.getService();
(只是指出我在 Java 错误方面有点缺乏经验)。
所以我决定创建一个小程序来测试 API 调用是否正在检索以及任何东西(我正在尝试从我的 soundcloud 帐户中获取曲目)
我收到了这个错误:
请帮助我认为这与我的 Retrofit.jar 库有关。我正在使用 Retrofit2.0.0-3beta 和 Eclipse IDE - 如何解决此问题以便能够从我的帐户中检索曲目?
upload - Android:Retrofit 2 多文件上传howto?
用改造2上传单张图片似乎没有问题。
但是,我不知道如何同时上传 2 张图片。
如果遵循文档: http ://square.github.io/retrofit/2.x/retrofit/retrofit2/http/PartMap.html
界面:
这给出了“上传:成功”,但在服务器端我得到了胡言乱语:
CONTENT_TYPE:多部分/表单数据;边界=50fbfeb3-3abc-4f15-b130-cdcb7e3a0e4f
内容发布:数组([file] => �PNG IHDR L alotofbinarygibberish.... ... snip [file2] => �PNG IHDR L 更多二进制乱码...
谁能指出我正确的方向?
单次上传确实有效,所以这不是问题,我正在尝试上传 2 张或更多图片。
如果我将其更改为:
我没有乱码,但只上传了第二张图片......!?
更新
我试过这个Retrofit(2.0 beta2) Multipart file upload doesn't work solution,但得到一个错误,@body can not me used with multipart: Java.lang.IllegalArgumentException: @Body parameters cannot be used with form or multi-part encoding。(参数#1)
-
android - 与糖 orm 和 gson 冲突
我的模型看起来像这样简化
当 Gson 尝试转换从改造收到的结果时,我收到错误消息。
当 Movie 不扩展 SugarRecord 时,它工作得非常好。
我可以在这里做什么?
java - 致命异常。使用 Retrofit2-beta3 无法使用 retrofit2 从 apiUrl 检索数据
我一直在使用 Android Studio IDE完成本教程。
我遇到的问题是本教程是使用较旧的 gson 库和改造 1.8.0 完成的......
我一直很好地使用retrofit2.0-beta3,直到我遇到了这个我似乎无法解决的错误..
它与这一行有关......(这一行在我的 MainActivity.Java 中 onCreate() 下)
所以我认为问题始于 scService 接口..
这是我的 Soundcloud 课程....
}
这是 Config 类认为不需要它...
我整天都在这,任何帮助将不胜感激..