AIDL

cluelin·2021년 12월 3일
0

Service

목록 보기
3/3

참조 - https://developer.android.com/guide/components/aidl

IPC 프로세스간 통신
멀티쓰레드.

여러 어플리케이션에서 멀티쓰레딩이 필요한경우에만 사용.
아닌경우에는 Bound Service의 다른 방법을 쓰는게 좋다.

// IRemoteService.aidl
package com.example.android

// Declare any non-default types here with import statements
/** Example service interface */
internal interface IRemoteService {
    /** Request the process ID of this service, to do evil things with it. */
    val pid:Int

    /** Demonstrates some basic types that you can use as parameters
     * and return values in AIDL.
     */
    fun basicTypes(anInt:Int, aLong:Long, aBoolean:Boolean, aFloat:Float,
                 aDouble:Double, aString:String)
}
private val binder = object : IRemoteService.Stub() {

    override fun getPid(): Int =
            Process.myPid()

    override fun basicTypes(
            anInt: Int,
            aLong: Long,
            aBoolean: Boolean,
            aFloat: Float,
            aDouble: Double,
            aString: String
    ) {
        // Does nothing
    }
}

0개의 댓글