Does an Intent's extras still get flattened into a Parcel even if the new activity is being started within the same task?
I was wondering...
So if you start a new activity via an intent,开发者_Python百科 the intent has to be serialized and deserialized because you may have to send the intent to a separate VM instance via IPC. But what if the PackageManager knows that your new activity will be created on the current task? It seems like a reasonably Googly optimization would be not to serialize the intent at all, since it's all happening inside the same VM. But then again, you can't just allow the new activity to use the same instance of each parcelable, because any changes made by the new activity would show up in the old activity and the programmer might not be expecting this.
So, is this optimization being done? Or do the extras always get marshalled and unmarshalled, no matter what?
A little experiment yielded the unexpected: If you add a Parcelable
to your intent it is indeed marshalled, even though you are not leaving the currently running VM.
So good the optimization you mentioned is not there, otherwise I would bet people would already misuse it :-)
精彩评论