It is necessary to transfer the List array from a separate class to the IntentService , which allows you to check in the background for new photos in the server.
I use VKApi to display photos. And made such a method in the class SearchPhotos :
public static List<SearchPhotosModel> getPhotosService(Long date) { VKParameters params = new VKParameters(); params . put(VKApiConst.DATE_START, date); final List<SearchPhotosModel> items = new ArrayList<>(); VKRequest request = new VKRequest("photos.search", params); request.executeWithListener(new VKRequest.VKRequestListener() { @Override public void onComplete(VKResponse response) { super.onComplete(response); try { JSONArray array = response.json.getJSONObject("response").getJSONArray("items"); if(array.length() > 0) { JSONObject object = array.getJSONObject(0); Log.d("PollServiceRESPONSE", object.toString()); SearchPhotosModel mod = new SearchPhotosModel(); mod.setOwner_id(object.getInt("owner_id")); mod.setDate(object.getInt("date")); items.add(mod); } } catch (JSONException e) { Log.i(TAG + "-ERROR", e.getMessage() + " ERO : " + e.toString()); } } @Override public void onError(VKError error) { super.onError(error); Log.d(TAG, "ERror Vk: " + error.errorMessage); } @Override public void onProgress(VKRequest.VKProgressType progressType, long bytesLoaded, long bytesTotal) { super.onProgress(progressType, bytesLoaded, bytesTotal); Log.i(TAG, progressType + " - " + bytesLoaded + " - " + bytesTotal); } }); return items; } And in the IntentService class, IntentService 'm trying to get a List array in this way.
List<SearchPhotosModel> mModel; //Дата в формате Unix - это просто числа для проверки mModel = SearchPhotos.getPhotosService(13255235213L); How can I pass this array?