You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you provide some clarification on this sentence:
...But we cannot use getService() here because the new
// service hasn't been added to the tracked services yet (we're in
// the process of adding). We have to decide on our own.
Why do you say that in the addingService() method the service is not tracked and we cannot use getService().
In this book I find the opposite (chapter 4.8 page 93)
You have to read this with the argument list in mind:
... we cannot use ServiceTracker.getService() here ....
Neil Bartlett in his book uses context.getService(ref), a completely different method.
Now you might ask, why shouldn't I simply use the service that I can get from the service reference passed to addingService(ServiceReference ref) as shown in the book? Well, because in general, you can have several instances of the same service at the same time and you don't know if the one being added is the preferred one. ServiceTracker.getService() would return the preferred one, if we could call it. But as we are in an "adding" callback (and not in an "added" callback, which doesn't exist), the service being added is not taken into account by ServiceTracker.getService() yet.
Please append any comments to this issue.
The text was updated successfully, but these errors were encountered: