Create an AIDL server
AIDL server app exposes an service.
An AIDL server is an app that does the actual work and sends back the result to requesting clients. One service can connects with multiple clients via Binders.
Steps:
Create a service, e.g.
CalculatorService extends ServiceCreate an Implementation of
ICalculator.Stub, lets name itCalculatorImplImplement methods:
object CalculatorImpl : ICalculator.Stub() { override fun add(a: Int, b: Int): Int { return a + b } }Expose your stub implementation with a service binder:
class CalculatorService : Service() { override fun onBind(intent: Intent): IBinder { return CalculatorImpl } }
Now your service is ready to be consumed by your clients, now let's create a client application.
Last updated