I have an android app that makes a Retrofit service call uploadPhoto
after the button click.
In this service call response I would like to receive a photo ID so I need to listen to the service response or error. I have the code that handles this
Signletons.retrofitService.uploadPhoto(photoData)
.subscribe(new Action1<Response<UploadResponse>>() {
@Override
public void call(Response<UploadResponse> response) {
// response.body().photoId
}
})
But when activity gets destroyed due to the orientation change, I unsubscribe from the above Observable and this may happen somewhere between my photo request was sent, but before the response is received. This means that I may upload the photo, but not get the photo ID.
What is the best way to handle this situation and to resubscribe after orientation changes to get the result I missed due to the orientation change?