Issue
So I have a foreground service displaying a few items, I want to perform some function in the enclosing service when I press on an item in the recycler view. I'm aware I can use an Instance
of the service, but it's a memory leak. I'm aware as well of the binding/unbinding methods between service and activity, but this I believe doesn't apply to my situation?
Solution
Normally everything you would like to execute in the Service should be implemented and then called using a Binder (if Service and App are in the same Process) and its onBind() method.
In your specific case I suppose your Service is the "owner" of the UI created by WindowManager (like a floating window), so:
- if Service and UI are in the same Thread, you can pass a Listener/Callback to it or use the common onBind() way
- if Service and UI are in different Theads: you need some kind of synchronization between them (Looper+Message, a Queue, etc...)
- if Service and UI are in different Process: you need to implement "AIDL" technique
Answered By - emandt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.