开发者

Does an Intent's extras still get flattened into a Parcel even if the new activity is being started within the same task?

开发者 https://www.devze.com 2022-12-23 01:00 出处:网络
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 vi

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 :-)

0

精彩评论

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