I am working on receiving live API data updates on my android app. I am against polling as it drains battery and not in favor of anything that requires to check data updates manually every 5 mins or so. Is there an easier way to achieve this without the app constantly polling or manually checking if the data has updated on the API side?
I was thinking of adding a listener to some sort of an update on the server, but not sure if that'll be a viable approach. I have referred to : How to do live updates on an android app and other threads online, but nothing really helps. Here's an example of how I retrieve my data currently with observables:
getCompositeDisposable().add(getDataManager()
.getGuestListApiCall(AppPreferencesHelper.getInstance().getCurrentUserId())
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(response -> {
// using the parsed response here.
}, throwable -> {
if (!isViewAttached()) {
return;
}
// handle the error here
if (throwable instanceof ANError) {
ANError anError = (ANError) throwable;
handleApiError(anError);
}
}));
Any idea how to go about this? Any sample app would be helpful with some sort of a dummy api that can help see the live update result.
Thanks in advance!