0

I am trying to make 2 applications which will interact with each other using AIDL.

Application 1: Will be a service.

Application 2: Will be Activity(with a button) which will show some data which will be fetched by Application 1 service.

Now to start this interaction I know we can make one AIDL file in both applications and when user presses the button in application 2 we can involve the function of service from application one. That is lets say application 2 requests the current time then application 1(Service) will fetch the current time and return it to application 2.

My doubt is that I want to interact the other way round. I want to inform the activity from service when some particular digit occurs in time(or some other event). I am not sure how to proceed with this way of communication ie from Service to Activity.

Some pointers will be really helpful.

learner
  • 1,095
  • 2
  • 18
  • 41

2 Answers2

0

You know you can send message from Activity to service, Reference Bound Service By Following above tutorial You should Consider Sending Handler from Activity to Service using Messenger Class in Intent. So now Service and Activity can send message to each other which will execute corresponding Handlers

Pankaj
  • 1,242
  • 1
  • 9
  • 21
0

Use Broadcast receiver in Activity and let Service broadcast messages (with same Intent as used by Broadcast receiver in Activity). These messages which are broadcasted from Service will be received by broadcast receiver in the Activity.