安卓:Parcelable和序列化之间的区别?区别、序列化、Parcelable

2023-09-11 20:17:52 作者:胸有大志

为什么Android的提供2接口,序列化对象?不要序列化对象interopt与Android 文件夹和AIDL文件?

Why does Android provide 2 interfaces for serializing objects? Do Serializable objects interopt with Android Binder and AIDL files?

推荐答案

序列化是一个标准的Java接口。您只需标记一个类通过实现该接口可序列化,和Java将它在某些情况下会自动进行序列化。

Serializable is a standard Java interface. You simply mark a class Serializable by implementing the interface, and Java will automatically serialize it in certain situations.

Parcelable 是你自己实现序列化的Andr​​oid的特定接口。它的建立可以更加高效的序列化,并解决一些问题,默认的Java序列化方案。

Parcelable is an Android specific interface where you implement the serialization yourself. It was created to be far more efficient that Serializable, and to get around some problems with the default Java serialization scheme.

我相信,活页夹和AIDL工作,Parcelable对象。

I believe that Binder and AIDL work with Parcelable objects.

不过,您可以在意图使用序列化对象。

However, you can use Serializable objects in Intents.