---
title: "Bundle传递对象后，内存中该对象地址的问题"
author: "jogickis"
date: "2013-12-17T09:54:21Z"
tags: ["bundle"]
categories: ["移动开发"]
slug: "bundle"
draft: false
lastmod: "2013-12-17T11:21:03Z"
id: 1990662
url: "https://jogickis.iteye.com/blog/1990662"
---

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