By default, AIDL supports the following data types:
- All primitive types in the Java programming language (such as
int
,long
,char
,boolean
, and so on) String
CharSequence
List
All elements in the
List
must be one of the supported data types in this list or one of the other AIDL-generated interfaces or parcelables you've declared. AList
may optionally be used as a "generic" class (for example,List<String>
). The actual concrete class that the other side receives is always anArrayList
, although the method is generated to use theList
interface.Map
All elements in the
Map
must be one of the supported data types in this list or one of the other AIDL-generated interfaces or parcelables you've declared. Generic maps, (such as those of the formMap<String,Integer>
are not supported. The actual concrete class that the other side receives is always aHashMap
, although the method is generated to use theMap
interface.
You must include an import
statement for each additional type not listed above, even if they are defined in the same package as your interface.
如果不是AIDL数据类型,需要自己定义一个新的AIDL文件并实现parcelable接口,示例如下:
For example, here is a Rect.aidl
file to create a Rect
class that's parcelable:
package android.graphics; // Declare Rect so AIDL can find it and knows that it implements // the parcelable protocol. parcelable Rect;
And here is an example of how the Rect
class implements theParcelable
protocol.
import android.os.Parcel; import android.os.Parcelable; public final class Rect implements Parcelable {
实体类的aidl应该在实体类所在的包名下