开发者

How to use ResultReceiver in AIDL

I'd like to declare an asynchronous service API in AIDL using ResultReceiver instead of creating my own callback interface.

But when I try to import android.os.ResultReceiver, it doesn't know that ResultReceiver is parcelable. Is there a trick?

Example:

import android.os.ResultReceiver;

interface IPrimeService {
    int computePrimes(in int number, in ResultReceiver resultReceiver);
}

Results in (Android 2.2):

IPrimeService.aidl:3: couldn't find import for class android.os.ResultReceiver

It seems if I create ResultReceiver.aidl in src/android/os within my project like:

package android.os;

parcelable ResultReceiver;

it works, but that seems like such a hack. Is there a better way?

开发者_如何学Go

Thanks, Eric


I ran into a similar issue.. I edited /platform/android-<#>/framework.aidl to include the line

parceable android.os.ResultReceiver;

and then it works

credit: http://amdroid.ampache.org/?p=38

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜