我正在使用RoboSpice的Retrofit。我正在调用REST调用,但是一个调用是一个问题,因为从不调用响应侦听器 - onRequestFailure()和onRequestSuccess()
...用户选择UI选项后
CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest("1001", "John", "Smith");
this.getSpiceManager().execute(createCustomerRequest, new CreateCustomerRequestListener());
private class CreateCustomerRequestListener implements com.octo.android.robospice.request.listener.RequestListener<ErrorResponse> {
@Override
public void onRequestFailure(SpiceException spiceException) {
// Never called
}
@Override
public void onRequestSuccess(ErrorResponse errorResponse) {
// Never called
}
}
public class CreateCustomerRequest extends RetrofitSpiceRequest<ErrorResponse, EmbarApi> {
private String id;
private String firstName;
private String lastName;
public CreateCustomerRequest(String id, String firstName, String lastName) {
super(ErrorResponse.class, EmbarApi.class);
this.id = id;
this.firstName = firstName;
this.lastName= lastName;
}
@Override
public ErrorResponse loadDataFromNetwork() throws Exception {
return getService().createCustomer(id, firstName, lastName);
}
我很困惑为什么不听电话听众。我看到很少有来自RS的记录(只是“主要添加请求队列”请求)这看起来很奇怪,但据我所知,RoboSpice完全失败,但完全是默默无闻的。由于我在应用程序中进行其他REST调用而没有问题,因此特别令人困惑。
答案 0 :(得分:7)
我希望你不要忘记调用spiceManager.start和spiceManager.shouldStop函数。
应分别在该上下文的onStart和onStop函数中调用它们。