-1

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.

Abx
  • 2,852
  • 4
  • 30
  • 50

1 Answers1

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.

Community
  • 1
  • 1
Sitram
  • 1,432
  • 1
  • 14
  • 17
  • I have thought about this.But,in my case I cant use a Localbroadcastreceiver – Abx Aug 25 '14 at 12:34
  • May I ask why you can't use it? – Sitram Aug 25 '14 at 12:36
  • 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