I was wondering if there is a way to have a listener for a Service.In my scenario I have a Service class S that is initiated by a class A . Service class S has a method S().I want to have a callback to class A when the method s() is done executing .Is it possible in any way .Any link or reference or even a code snipet will be realy appreciated.
Asked
Active
Viewed 32 times
1 Answers
3
Use a Localbroadcastreceiver to notify the activity when method S() finished execution.
Check this question for details about how to use a Localbroadcastreceiver
There is no such thing as listener for a service.
-
I have thought about this.But,in my case I cant use a Localbroadcastreceiver – Abx Aug 25 '14 at 12:34
-
-
What about a Communication between Activity and Service using Messaging like in this answer - http://stackoverflow.com/questions/4300291/example-communication-between-activity-and-service-using-messaging?rq=1 – Sitram Aug 25 '14 at 12:39
-
Am starting the service to detect a call from a particular number,for that I created a lib.So am not using any activity etc.Correct me if am wrong – Abx Aug 25 '14 at 12:40
-
Sorry I cannot help you here, I don't have experience with libraries in Android yet. Maybe see if the binding/unbinding to a service and the messaging mechanism from the second link might help you. – Sitram Aug 25 '14 at 12:46