arkadiy
04/20/2016, 9:41 AMGpsService without Activity because in your approach it passes result in `OnActivityResult`; why in the world I should know about this fact and why I simply cannot pass functions to handle results instead of creating such tight coupling to Activity lifecycle?
On the other hand, I cannot test Activity without full-blown GpsService instead of a mock, if I want to test some other Activity functionality. A DI framework might be a solution here, but almost all of them require a lot of boilerplate to write, and this simply would not be a problem if I could simply pass a subclass of GpsService in constructor.
2) Sorry, what? I'm saying that in your case, you now have to either compare in your Activity onActivityResult() method the requestCode and resultCode with GpsService requestCode and resultCode or move the very same logic to it; this approach forces to write more code for no reason at all + creates yet another coupling between GpsService and Activity meaning that GpsService cannot work without either Activity specifics, or without implementing some kind of interface (which is effectively the same).
Okay, another example of this problem:
Say, you have 2 activities, user switches between them and in both of which you need to maintain the same connection to a WebSocket on server; but when user closes/stops/hides the app you need to disconnect from the socket. How would you do it?