Remoter

Remoter - An alternative to Android AIDL for Android Remote IPC services using plain java interfaces

Remoter makes developing android remote services intuitive without messing with AIDL.

Android IPC through AIDL

Android supports remote IPC using AIDL. This process of using “aidl” is painful and limited.

Some of the problems and limitations of AIDL are :

Remoter - An intuitive way for Android IPC

Remoter solves the above problems in AIDL by allowing you to define the remote interface using plain java interface, and implement it using plain java implementation of the interface.

All you have to do is annotate the interface using @Remoter

@Remoter
public interface ISampleService {
    ...
}

At the client side

ISampleService sampleService = new ISampleService_Proxy( binder );

At the service side

Binder binder = new ISampleService_Stub( sampleServiceImpl );

That’s it!

Annotations

Kotlin Support with suspend functions

Remoter supports Kotlin interfaces with suspend functions. If your interface (marked with @Remoter) has any suspend functions, then the generated Proxy and Stub will be in Kotlin, enabling to call your remoter service method from coroutines.

Kotlin Example
@Remoter
interface ISampleService {

    /**
     * A suspend function which will be implemented by a service
     */
    suspend fun authenticate(userName:String, password:String) : Boolean
}

implementation 'com.josesamuel:remoter-builder:<VERSION>'

//From your coroutine context - 

//create service using serviceintent
val service = ISampleService_Proxy(context, SERVICE_INTENT)

//call the suspend function
val authenticated = service.authenticate(userName, password)

//The above call will 
 - suspend the current context
 - connect to service, 
 - make the remote call, 

 all sequentially without blocking the calling thread!
 
Notes on Kotlin support

Getting Remoter

Gradle dependency

dependencies {

    implementation 'com.josesamuel:remoter-annotations:2.0.0'
    kapt 'com.josesamuel:remoter:2.0.0'
    
    
    //If using kotlin coroutines, include following 
    //to make even the service connection simpler - 
    
    implementation 'com.josesamuel:remoter-builder:2.0.0'
    
}

License

Copyright 2017 Joseph Samuel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.