should i put my retrofit calls inside and Android Service class? for my application iam calling retrofit inside in some classes for example like below
Call<ArrayList<CantItem>> mycall = retrofitcalls.getCanteenItems("url.php", urldatamap);
mycall.enqueue(new Callback<ArrayList<CantItem>>() {
@Override
public void onResponse(Response<ArrayList<CantItem>> response, Retrofit retrofit) {
int code = response.code();
Log.d("code ", String.valueOf(code));
if (code == 200 || code == 201) {
ArrayList<CantItem> cantitems = response.body();
Log.d("retrieved", "returned items");
savedToSharedPrefs(createString(cantitems));
cantmap = createMap(cantitems);
presenter.updateView(cantmap);
}
}
@Override
public void onFailure(Throwable t) {
Log.d("couldnt retrieve", "failure");
}
});
I was wondering should i put this call inside an Android Service class? as my retrofit call runs asynchronously anyway? Every tutorial ive seen seems to run it in either classes or activities. I haven't seen anyone using a service. Im not 100% sure what the best approach is at present. thanks