I send data between my activity and my service through an intent ( i call startForegroundService multiple times because this call onStartCommand again and with getIntent i fetch my data).
Example:
Intent intent = new Intent(getActivity(), MediaPlayerService.class);
intent.putParcelableArrayListExtra("songList", Main.musicList);
intent.putExtra("songIndex", position);
intent.setAction(Constants.ACTIONS.ACTION_PLAY);
ContextCompat.startForegroundService(getActivity(), intent);
I read somewhere it's better to communicate with my service through binding.
But i'm achieving the same thing with this method, so which one is preferable?