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?

  • Tell me again, what, from where and where to go? - tse
  • I correctly understand that the code you give does not return the values ​​you need to the mModel variable, the service stops working, and you don’t understand why? - Yuriy SPb
  • From the getPhotosService method via Return to another class is not passed. I need to check the date of the last photo output from VK in the IntentService, if there are still new ones to inform the user about it. And in order to do this, I need this function to display this date for me, but for some reason the array is not passed from the onComplete () method through Return. I hope I clearly explained ( - bellator001
  • FROM this method getPhotosService () It is necessary to transfer the List array to the new IntentService class. getPhotosService this method is in the class of SearhPhotos - bellator001

0