I need to grab a service synchronously in Android. I’m sure it’s already running, I just need to access it in my adapter. Should I just pass a reference once the service becomes available, or can I use something to the effect of context.getService(...) to get it? What is the recommended solution?
I need to grab a service synchronously in Android. I’m sure it’s already running,
Share
I believe you have an activity where the adapter is created and destroyed. Therefore the adapter’s lifecycle should match the lifecycle of your activity. The conclusion would be to pass a reference of the service to the adapter on its creation, as it is the activity that binds and unbinds the service. 🙂