I know that Service can have a reference to Activity. Does the opposite hold ?
I have a service that monitor my Audio play/pause/stop . In my activity, I have 3 buttons for these functions and a seek bar also.
I want to call the appropriate function at the Service when the corresponding button is pressed at the Activty. Also I want the seekBar to set its max to the Audio length at the service. So, I figured that I need a reference to my service in order to do that.
Am I right or what?
Services should not hold references to activities, as this may result in memory leaks. An Activity can have a reference to a Service, this is called "Local Bound Services". A detailed explanation of what this is and how to implement and use it described in "Bound Services" article in Android's documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With