retrofit2

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 3 column 1 path $

余生颓废 提交于 2019-12-31 07:53:09
问题 I am using retrofit2 with Gson Converter. my server response is : { "resonse": { "status": 200, "result": [ { "video_id": "3c19979979", "video_title": "Sushil Kumar Modi press conference after serial bomb blasts at Modi rally in Patna", "video_description": "BJP at Patna serial blast in Bihar, Nitish government has stood in the dock. Former Deputy Chief Minister Sushil Kumar Modi said the blasts Narendra Modi were targeted. He said that Nitish Kumar look Modi as the enemy.<br />\r\n", "video

Retrofit 2 without Model Class

南楼画角 提交于 2019-12-31 05:31:10
问题 i want to ask about Retrofit 2.0 all this time, i knew Retrofit only with GSON Converter and get the object. But i dont know how to get the data with API like this https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty i'm trying to display all top stories and get the object after i load all the top stories first. i only know with old school style like this: http://pastebin.com/JMpwjH8H 回答1: I'm pretty sure for your example you can just set the response type as a list of Integers

Call another Retrofit call on Subject emission

折月煮酒 提交于 2019-12-31 05:19:25
问题 I have a following class: public class SessionStore { Subject<Session, Session> subject; public SessionStore() { subject = new SerializedSubject<>(BehaviorSubject.create(new Session()); } public void set(Session session) { subject.onNext(session); } public Observable<UserSession> observe() { return subject.distinctUntilChanged(); } } In activity I observe the session and perform network operation on each change: private Subscription init() { return sessionStore .observe() .flatMap(new Func1

How can I update Activity/Fragment UI from Retrofit onResponse()?

ⅰ亾dé卋堺 提交于 2019-12-31 03:40:56
问题 I want to use Retrofit 2.1.0 for my next Android project. I would like to use Design Pattern and therefore create separate classes for every REST call i.e IBalanceService.java public Interface IBalanceService{ @GET("users/{username}") void getUser(@Path("username") String username, Callback<User> cb); } BalanceRestClient.java public class BalanceRestClient{ String username = "Makarov"; Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://hovermind.com") .addConverterFactory

POST Streaming Audio over HTTP/2 in Android

血红的双手。 提交于 2019-12-31 00:55:07
问题 Some background: I am trying to develop a voice-related feature on the android app where a user can search using voice and the server sends intermediate results while user is speaking (which in turn updates the UI) and the final result when the query is complete. Since the server accepts only HTTP/2 single socket connection and Android HTTPUrlConnection doesn't support HTTP/2 yet, I am using Retrofit2. I have looked at this, this and this but each example has fixed length data or the size can

Retrofit 2: How to handle dynamic response

让人想犯罪 __ 提交于 2019-12-30 11:21:05
问题 I am trying fetch data from this api: http://www.omdbapi.com/ I am using Retrofit 2 and created a pojo for first json. The thing I am curious about is how to convert my pojo to second one when data is not available. When there is data available, It returns this json: http://www.omdbapi.com/?t=Suits { Title: "Suits", Year: "2011–", Rated: "TV-14", Released: "23 Jun 2011", Runtime: "44 min", Genre: "Comedy, Drama", Director: "N/A", Writer: "Aaron Korsh", Actors: "Gabriel Macht, Patrick J. Adams

Kotlin 1.2.21 + SimpleXml 2.3.0 - consume List error (must mark set get method)

倖福魔咒の 提交于 2019-12-30 08:22:30
问题 I'm trying to consume XML using SimpleXML by Retrofit 2. After hours of struggling with Kotlin I decided to try Java version and the convert then to Kotlin. And Java version worked well... error: java.lang.RuntimeException: org.simpleframework.xml.core.MethodException: Annotation @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=true, name=entry, required=true, type=void) must mark a set or get method I need a Kotlin model class that will be able to consume that XML.

Kotlin 1.2.21 + SimpleXml 2.3.0 - consume List error (must mark set get method)

给你一囗甜甜゛ 提交于 2019-12-30 08:21:26
问题 I'm trying to consume XML using SimpleXML by Retrofit 2. After hours of struggling with Kotlin I decided to try Java version and the convert then to Kotlin. And Java version worked well... error: java.lang.RuntimeException: org.simpleframework.xml.core.MethodException: Annotation @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=true, name=entry, required=true, type=void) must mark a set or get method I need a Kotlin model class that will be able to consume that XML.

Retrofit,onResponse method doesnt work

寵の児 提交于 2019-12-30 07:48:13
问题 Im new in Retrofit,try to get data from one web server,create Model,Interface but this still not working.Problem(maybe) in method onResponse() I add to that method Log.d and Toast but I dont see Log and Toast when launch my app.Why that dont work? I can understand when I get wrong response or something else,but onResponse() dont work in general,how I think.Maybe Toast cant work withoud data,but Log.d must work without it,and Log.d havent data,just code of response. I added all depencies and

RxJava 2 / Retrofit 2 - NetworkOnMainThreadException

空扰寡人 提交于 2019-12-30 06:43:06
问题 I need to perform a request, if my token is expired I need to refresh it and retry the request. This is how I'm trying to do it, at the moment I can refresh the token but it throws me a NetworkOnMainThreadException. It finishes the request,update the token and reaches logs, but that exception its killing me. How can I avoid that? public Observable<Estabelecimento> listarEstabelecimentos() { return Observable.defer(this::getListarEstabelecimentoObservable) .retryWhen(throwableObservable ->