开发者

How to pass complex data structures (example: a vector with many elements) between service and the remote binder?

开发者 https://www.devze.com 2022-12-20 15:14 出处:网络
The object passing between an Android service and the remote binder is happening thr开发者_如何学运维ough serialization of the object.If the service needs to return a very large collection, it seems v

The object passing between an Android service and the remote binder is happening thr开发者_如何学运维ough serialization of the object. If the service needs to return a very large collection, it seems very inefficient to use this. What is the recommended way to deal with this?

Thanks.


In Android you should implement Parcelable rather than Serializable on your objects, as the performance is much better. Your AIDL method can then specifiy a Parcel as an argument.

Here's the SDK documentation about passing Parcelable objects to a Service which has some sample code.

0

精彩评论

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