android.location.Address不能被AIDL识别



我试图从远程服务传递回List<Address>对象,我似乎无法弄清楚为什么会发生这种情况,但是当我尝试将import android.location.Address放入我的Android AIDL文件时,我的IDE (Eclipse)将导入高亮显示为错误。这很奇怪,因为Address实现了Parcelable接口(android.location也是如此)。位置,它不会被高亮显示为错误),所以我希望这样做没有问题。知道是怎么回事吗?

我使用的Android平台是4.2.2 Jelly Bean。

虽然android.location.Address实现了Parcelable接口,但它似乎没有在sdk/platforms/android-<api-level>/framework.aidl中声明为parcelable。作为一种解决方法,您可以添加以下行:

parcelable android.location.Address;

framework.aidl文件对应的API级别(在4.2.2 JellyBean的情况下为17)。

与直接修改framework.aidl文件相比,我更喜欢的另一种方法是在src/android/location/Address.aidl的项目中添加一个包含parcelable声明的AIDL接口文件,其中包含:

package android.location;
parcelable Address;

为什么android.location.Address不首先在framework.aidl中声明为parcelable,我不知道。

最新更新