问题
Ideally I would like to send an object of type
ArrayList<ArrayList<ASimpleClass>>
from a remote service in one APK to an application in another. I'm not sure if this is even possible as the API demo code suggests that it isn't:
/**
* This demonstrates the basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
whilst the autocomplete for writeTo/readFromParcel suggests that other types are an option (though read options don't match write). I would settle for just ArrayList if necessary. If it is possible, I'd much appreciate a pointer to some sample code, or a way to cast the above types into something acceptable to the remote interface AIDL. Can anyone shed any light on this question please?
回答1:
http://developer.android.com/reference/android/os/Parcel.html
If what you want isn't on the list of supported methods, you can still send it provided that you write code to dump it out to a series of supported types and rebuild it on the other side.
来源:https://stackoverflow.com/questions/3988609/complex-types-from-a-remote-service-to-an-application-through-aidl