发生在序列化对象是什么?如何保持观察员throuout序列化? [英] What happens to objects on serialization? How to keep Observers throuout serialization?

查看:208
本文介绍了发生在序列化对象是什么?如何保持观察员throuout序列化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做下面的一个活动:

  intent.putExtra(searchRegion,searchRegion);
    Log.d(AAA,Puttin searchRegion:+ searchRegion.toString());

和在接收活动:

  SearchRegion searchRegion =(SearchRegion)getIntent()getSerializableExtra(searchRegion);
    Log.d(AAA,RCV searchreg+ searchRegion.toString());

的结果是:

  Puttin searchRegion:mypackage.SearchRegion@3b41ba0
RCV searchreg mypackage.SearchRegion@22655d14

我意识到这一点时,我不知道那里的观察是我SearchRegion对象的序列化之后已经走了。

我有两个问题:


  1. 通过我的序列化对象时,到底发生了什么意图?在接收端的对象不一样,在发送端的对象,对不对?

  2. 我可以保持观察取值整个系列化对象与意图


解决方案

  

什么通过序列化意图我对象时究竟发生?


由这些对象保持的数据,以及关于什么的对象的类,被写入到流的元数据,然后从该流重构


  

在接收端的目的是不一样的在发送端的对象,对不对?


正确的。


  

我可以保持一个对象的观察员整个系列化意图?


没有。

I do the following in one Activity:

    intent.putExtra("searchRegion", searchRegion);
    Log.d("AAA", "Puttin searchRegion: " + searchRegion.toString());

and on the receiving Activity:

    SearchRegion searchRegion = (SearchRegion) getIntent().getSerializableExtra("searchRegion");
    Log.d("AAA", "rcv searchreg " + searchRegion.toString());

The result is:

Puttin searchRegion: mypackage.SearchRegion@3b41ba0
rcv searchreg mypackage.SearchRegion@22655d14

I realized this when I wondered where the Observers of my SearchRegion objects had gone after serialization.

I have two questions:

  1. What exactly happens when serializing my object through the Intent? The object on the receiving end is not the same as the object on the sending end, right?
  2. Can I keep the Observers of an object throughout serialization with Intent?

解决方案

What exactly happens when serializing my object through the Intent?

The data held by those objects, plus metadata about what the classes of the objects are, are written to a stream, then reconstituted from that stream.

The object on the receiving end is not the same as the object on the sending end, right?

Correct.

Can I keep the Observers of an object throughout serialization with Intent?

No.

这篇关于发生在序列化对象是什么?如何保持观察员throuout序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆