我不是问我该如何使用它,也不是它做什么,它是如何工作的 。 当我问到为什么他们只是放一个putExtra(String,Object)以便我可以传递一个对象时,问题就出现了。 显然他们只是没有忘记这样做,而不是Bundle工作的方式不是你能做到的。
PS: Serializable或Parcelable是你无法在你创建的每个类上实现的东西,因此它们不能替代putExtra(String,Object)
I'm not asking how do I use it nor what does it do, how does it works. The question came to me when I though why didn't they just put a putExtra(String,Object) so I can pass an object. Obviously they just didn't forgot to do it, rather than the way Bundle works isn't one you can just do that.
PS: Serializable or Parcelable is something you cannot implement on every class you create, so they are not a replacement for putExtra(String,Object)
最满意答案
显然他们只是没有忘记这样做
正确。
Bundle本身就是Parcelable,正如Doctoror Drive所说。 Parcelable背后的要点是能够将它放入一个Parcel ,并且Parcel后面的点是跨越进程边界传递数据。 您不能跨进程边界传递任意对象,就像您无法将任意对象写入文件而无法通过套接字流传输任意对象一样。
Obviously they just didn't forgot to do it
Correct.
A Bundle itself is Parcelable, as Doctoror Drive notes. The point behind a Parcelable is to be able to place it into a Parcel, and the point behind a Parcel is to pass the data across process boundaries. You cannot pass arbitrary objects across process boundaries, just as you cannot write arbitrary objects to a file and cannot stream arbitrary objects over a socket.
更多推荐
发布评论