读书人

Bundle传递对象后内存中该对象地址的

发布时间: 2013-12-22 15:06:55 作者: rapoo

Bundle传递对象后,内存中该对象地址的问题
Bundle bundle = new Bundle();bundle.putSerializable("custom", MyApplication.getInstance().getCustom());mFragmentPersonal.setArguments(bundle);



custom = (Custom)getArguments().getSerializable("custom");



然后再通过MyApplication.getInstance().getCustom()的对象一直为null

没看源代码,以后探索,我觉得是Bundle在传递对象后,只能通过Key的方式获取,该对象以前的内存地址内容清空了。

?

然后我在考虑 是不是只是清空了该内存地址的一个引用,于是使用

?

?

Custom cus =  MyApplication.getInstance().getCustom();bundle.putSerializable("custom", cus);

?

结果还是为null,说明不是清空一个引用

?

确认的之前和之后的Application是同一个对象

?

读书人网 >移动开发

热点推荐