犯了个错误,以前从没注意过(主要是没写错过)
put的key与get的key大小写不一样导致无法取到值
看了下bundle的数据存储,原来是HashMap<String,Object>,好吧,释然了.
static {
EMPTY = new Bundle();
EMPTY.mMap = Collections.unmodifiableMap(new HashMap<String, Object>());
}
// Invariant - exactly one of mMap / mParcelledData will be null
// (except inside a call to unparcel)
/* package */ Map<String, Object> mMap = null;
/**
* Inserts a String value into the mapping of this Bundle, replacing
* any existing value for the given key. Either key or value may be null.
*
* @param key a String, or null
* @param value a String, or null
*/
public void putString(String key, String value) {
unparcel();
mMap.put(key, value);
}
/**
* Returns the value associated with the given key, or null if
* no mapping of the desired type exists for the given key or a null
* value is explicitly associated with the key.
*
* @param key a String, or null
* @return a String value, or null
*/
public String getString(String key) {
unparcel();
final Object o = mMap.get(key);
try {
return (String) o;
} catch (ClassCastException e) {
typeWarning(key, o, "String", e);
return null;
}
}