Pregunta

If I send a Parcelable object to another part of my program via LocalBroadcastManager -is the Parcelable immutable then? Immutable in the sense that the received Parcelable cant affect the object that was originally transmitted. I would guess so, because I guess Parcelable is a "deepcopy" serialization mechanism and not pass by reference, but I need to be sure. Can someone who knows, tell me if I have to worry about someone in the receiving end changing values on the received object, if I want to prevent that from affecting the original object...?

¿Fue útil?

Solución

If I send a Parcelable object to another part of my program via LocalBroadcastManager -is the Parcelable immutable then?

That is not guaranteed. In fact, AFAIK, it does not happen at all for local broadcasts.

I guess Parcelable is a "deepcopy" serialization mechanism and not pass by reference

Only across process boundaries. That happens to include things like startActivity() for another one of your activities, because those involve IPC. But the Intent object -- and its extras -- is simply passed around your process with LocalBroadcastManager. I see no place where Intent would be forced to make a copy.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top