Stephan GM
Stephan GM

Reputation: 245

Asynchronous communication from a system service to other apps

I have a system service that runs constantly in the background and gets asynchronous interrupts through I/O. I want to be able to let other apps know when an interrupt occurs and the nature of that interrupt. I want to make this information available for a multitude of different and unknown apps.

I've been reading about binding and about broadcasting intents (I'm pretty sure there are more than just these two ways). In this scenario, what method of communication would be best to send this information out and make it generally available?

Upvotes: 1

Views: 70

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006624

The "long periods of inactivity" means that the "different and unknown apps" shouldn't be running just waiting for your IPC. Hence, you not only need to deliver the message, but you need to ensure that the recipient has a process running as part of that.

I presume that the simplest solution would be the broadcast Intent. This will:

  • Allow recipients to register in the manifest to receive the broadcast, so their process can be started up if needed without additional work on your part

  • Have a simplified "fire and forget" approach from your side

I have not implemented a system service. I presume that sending a broadcast from one is not that tough.

Other things to consider:

  • If possible, figure out a batching system. Your top rate of 15-20/second isn't nearly as bad as, say, sensor readings, but it's still a bit frequent.

  • Ponder what sort of security you will need for this (e.g., custom permission?).

Upvotes: 1

Related Questions