Create an AIDL server
AIDL server app exposes an service.
Last updated
AIDL server app exposes an service.
Last updated
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 Service
Create an Implementation of ICalculator.Stub
, lets name it CalculatorImpl
Implement 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.