android get请求最长字符串,android – Retrofit @GET – 如何显示请求字符串?

我正在使用一个使用Retrofit创建一个休息的客户端的

Android应用程序.为了调试网络调用,我想显示或转储实际被调用的url.有没有办法做到这一点?我已经在下面列出了一些代码,显示了应用程序当前如何使用改进.

客户端界面定义:

import retrofit.Callback;

import retrofit.http.Body;

import retrofit.http.GET;

import retrofit.http.Headers;

import retrofit.http.POST;

import retrofit.http.Path;

// etc...

public interface MyApiClient {

@Headers({

"Connection: close"

})

@GET("/{userId}/{itemId}/getCost.do")

public void get(@Path("userId") String userId,@Path("itemId") String userId,Callback callback);

//....etc

}

使用生成客户端的服务:

// etc...

import javax.inject.Inject;

import retrofit.Callback;

import retrofit.RetrofitError;

import retrofit.client.Response;

@Inject

MyApiClient myApiClient;

// etc...

myApiClient.getCost(myId,itemId,new Callback() {

@Override

public void success(Cost cost,Response response) {

Log.d("Success: %s",String.valueOf(cost.cost));

if (cost.cost != -1) {

processFoundCost(cost);

} else {

processMissingCost(itemId);

}

stopTask();

}

@Override

public void failure(RetrofitError error) {

handleFailure(new CostFailedEvent(),null);

}

});

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值