What are the pros and cons of using aidl vs broadcast receivers for sending messages between apps (for both background and foreground handling)? I've been using receivers which is nice due to the subscription model with intent filters, and the ease of use / extensibility. Are there drawbacks to using this approach to vs AIDL?
Thx Ben
When sending data via an intent, you should be careful to limit the data size to a few KB. Sending too much data can cause the system to throw a TransactionTooLargeException exception. https://developer.android.com/guide/components/activities/parcelables-and-bundles
The statements that Intents could transfer up to 1Mb worth of data are definitely wrong, 500Kb is more accurate. https://www.neotechsoftware.com/blog/android-intent-size-limit"
It is Synchronous and Asynchronous inter process communication. By default,the AIDL communication is synchronous. In order to make AIDL communication asynchronous, use “oneway” keyword.
Complexity is high - AIDL interface sends simultaneous requests to the service, which must handle multi-threading.
One to One communication
Using the underlying Android OS Binder framework
Requires writing thread-safe code.
The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. https://developer.android.com/reference/android/os/TransactionTooLargeException.html"
Security: AIDL is allows developers to expose their interfaces to other application. Both the client and service agree upon in order to communicate with each other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With