I'm new to Retrofit 2.0. I'm making a standard call to get the data back:
final Call<HomeFeedContainer> call = service.getHomeFeed(token, placement);
call.enqueue(new Callback<HomeFeedContainer>() {
@Override
public void onResponse(Call<HomeFeedContainer> call, Response<HomeFeedContainer> response) {
//stuff
}
@Override
public void onFailure(Call<HomeFeedContainer> call, Throwable t) {
//stuff
}
});
I noticed that the call completes successfully even if I suspend/kill the application. I would like to use call.cancel() when this happens, but I don't have access to this local object in onPause(). If I make Call a member of my class, I can certainly cancel the call in onPause(), but I can't use the Call object to make another call. I'll have to set this to a new Call object if I want to make the call again. This doesn't seem like the right approach.
How should I be handling my Call objects when the user suspends the app? Thx.