2014-07-17 190 views
2

我正在使用RoboSpice進行Retrofit。我在做REST調用的地方好,但一個電話是一個問題,因爲響應監聽器永遠不會被調用 - 既不onRequestFailure(),也不onRequestSuccess()爲什麼Robospice響應偵聽器方法不被調用?

活動

...用戶選擇界面後,選項

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調用而沒有問題。

+3

我希望你不要忘記調用spiceManager.start和apiceManager.shouldStop函數。 – jsidera

+1

@jsidera你應該添加它作爲答案,因爲那完全是我忘記了 –

回答

6

我希望你不要忘記調用spiceManager.start和spiceManager.shouldStop函數。

它們應該分別在onStart和onStop函數中被調用。

相關問題