如何在AIDL中使用ResultReceiver
我想使用 ResultReceiver 在 AIDL 中声明异步服务 API,而不是创建自己的回调接口。
但是当我尝试导入 android.os.ResultReceiver 时,它不知道 ResultReceiver 是可打包的。有什么窍门吗?
示例:
import android.os.ResultReceiver;
interface IPrimeService {
int computePrimes(in int number, in ResultReceiver resultReceiver);
}
结果(Android 2.2):
IPrimeService.aidl:3: couldn't find import for class android.os.ResultReceiver
似乎如果我在项目中的 src/android/os 中创建 ResultReceiver.aidl ,就像:
package android.os;
parcelable ResultReceiver;
它可以工作,但这看起来像是一个黑客。有更好的办法吗?
谢谢,埃里克
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?
Thanks, Eric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题..我编辑了 /platform/android-<#>/framework.aidl 以包含
parceable android.os.ResultReceiver;
行然后它就可以工作了
:http://amdroid.ampache.org/?p=38
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