Maybe I should explain me better through an answer better than a comment.
You can do what you want doing this.
Object tmp = bundle.get(key);
if (tmp instanceof Boolean) {
boolean finalValue = ((Boolean)tmp).booleanValue();
}
If you check the source from Android you will see something similar, they always pass the wrapper not the primitive type.
public boolean More ...getBoolean(String key, boolean defaultValue) {
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Boolean) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Boolean", defaultValue, e);
return defaultValue;
}
}
The difference is that they do not check the type of the object as they suppose you know what you are doing.