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

在Fragment中传递 对象时发现了一个问题:将Appcation中全局对象传递一次后,发现该对象一直为null,这让我很郁闷

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是同一个对象

扫描二维码关注公众号,回复: 618855 查看本文章

猜你喜欢

转载自jogickis.iteye.com/blog/1990662