Robospice/retrofit 라이브러리를 처음 사용했습니다. github에서 몇 가지 샘플을 얻었습니다. https://github.com/octo-online/RoboSpice-samples/tree/release/robospice-sample-retrofit.Android - Robospice/retrofit에서 JSON 형식 요청 및 응답을받는 방법
내 이해 :
요청이 "githubRequest"이고 응답이 "Contributor.List"입니다. 웹 서비스는 getSpiceManager(). execute에 의해 호출됩니다.
코드 조각 : 내 질문이
@Override
protected void onStart() {
super.onStart();
getSpiceManager().execute(githubRequest, "github", DurationInMillis.ONE_MINUTE, new ListContributorRequestListener());
}
public final class ListContributorRequestListener implements RequestListener<Contributor.List> {
@Override
public void onRequestFailure(SpiceException spiceException) {
Toast.makeText(SampleSpiceActivity.this, "failure", Toast.LENGTH_SHORT).show();
}
@Override
public void onRequestSuccess(final Contributor.List result) {
Toast.makeText(SampleSpiceActivity.this, "success", Toast.LENGTH_SHORT).show();
updateContributors(result);
}
}
: 나는, 응용 프로그램에서 확인 할 올바른 JSONs이로 전송 요청/응답 ("githubRequest"/ "Contributor.List") 여부 서비스. 그렇다면 어떻게하면 JSON 요청 및 응답을 sysout 할 수 있을까요? 그러나 요청/응답은 POJO 객체입니다. 하지만 JSON 요청 및 응답을 인쇄하려면 어떻게해야합니까? 아무도 내가이 일을하도록 도와 줄 수 있습니까?
안드로이드 로그의 크기가 제한됩니다, 그래서 당신은 몇 가지 큰 요청을하는 경우에 당신은 당신이에 관심이있을 수있는 몇 가지 특정 세부 사항을 볼 수 없습니다. 개인적으로는 요청을 얻기 위해 찰스 프록시를 사용/답변, 설치가 매우 쉽습니다. http://jaanus.com/blog/2012/02/12/debugging-http-on-an-android-phone-or-tablet-with-charles-proxy-for-fun- 및 이익 /. 어쩌면 그것은 당신을 위해서도 효과가있을 것입니다. –
@Karolina Rusin : 방금 "githubRequest"에 두 개의 매개 변수를 보냈습니다. Robospice/retrofit 라이브러리를 사용할 때 JSON 요청/응답을받을 수 있습니까? – SKK