Answer the question
In order to leave comments, you need to log in
Why can the characters in the server response change?
interface GetInfo {
@GET("{url}")
Call<Object> getData(@Path("url") String url);
}
final TextView tt=findViewById(R.id.tt);
final String server = "https://rest-fns-check.herokuapp.com/check/";
final Gson gson = new GsonBuilder().create();
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gson))
.baseUrl(server)
.build();
GetInfo info = retrofit.create(GetInfo.class);
Call<Object> call = info.getData(address);
call.enqueue(new Callback<Object>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
tt.setText(response.body().toString());//map.get("raw_response"));
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
}
});
Answer the question
In order to leave comments, you need to log in
body().toString() returns a beautified JSON. Of course, : will be replaced by =.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question