0

I have created an accessibility service for my app where it would detect of the current outgoing call is answered or not but now i want create a callback function to my activity when the call is answered.

I have found some code to make callbacks from service in below links -

Callback from Service

RESTFul API

but i cant figure out a way to do that with my accessibility service, as i am not starting the service, android is, so there is no way to pass an object to the service.

If anyone can help please share.

kaustav07
  • 284
  • 3
  • 17

1 Answers1

1

Your service and your activity are separate processes. They cannot communicate directly. You should look into BroadcastReceiver. Note, though, that the user would have had to start your activity and have it running in the background. If the system decides it is low on memory and kills your activity completely, there is nothing you can do. You will not reliably get this broadcast with your activity in the background. You could try starting a background process from your activity for the sake of finding this event and storing the results somewhere for future consumption. Depends of course on your use case.

MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • Well thanks for your answer, but i already found a solution, a very useful library called [EventBus](https://github.com/greenrobot/EventBus) , you also can check it out, and thanks for sharing. – kaustav07 Jul 11 '17 at 21:29