🤖
Android Tips
  • 🤖AOSP
    • Clone AOSP repository
    • Directory Structure
    • Setup IDE
      • Setup VSCode
    • Build
      • BluePrint for Application Project
      • BluePrint for Android Library Project
    • Manifest
      • sharedUserId
      • persistant
  • Gradle
    • Create Custom Build Config Variables
    • Create Custom manifest Variables
    • Make app debugable
  • Android Process
    • Find a process by name
    • Kill a process by Id
  • Catch any exception in Android
  • 🎨Theming
    • Theming
      • RRO
        • RRO Internals
        • RRO classes in AOSP
        • RRO Example
        • RRO Permission
      • Fabricated RRO (FRRO)
        • FRRO Example
        • Permission
  • Lifecycle
    • Basics
      • Lifecycle
        • Activity
        • Fragment
          • Fragment add
    • Lifecycle Aware Custom Class
  • â„šī¸Interview
    • Interview Questions
    • Architecture Pattern
      • MVC Architecture pattern
      • MVP Architecture Pattern
      • MVVM Architecture Pattern
  • â†”ī¸AIDL
    • Simple AIDL Communication
      • Creating an AIDL file
      • Create an AIDL server
      • Create AIDL client
      • Limitations
    • AIDL with callback
      • Create AILD interfaces
      • Create an AIDL server
      • Create AIDL client
Powered by GitBook
On this page
  1. AIDL
  2. Simple AIDL Communication

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:

  1. Create a service, e.g. CalculatorService extends Service

  2. Create an Implementation of ICalculator.Stub, lets name it CalculatorImpl

  3. Implement methods:

     object CalculatorImpl : ICalculator.Stub() {
         override fun add(a: Int, b: Int): Int {
             return a + b
         }
     }
  4. 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.

PreviousCreating an AIDL fileNextCreate AIDL client

Last updated 1 year ago

â†”ī¸