bundle.putBoolean() bug?
I am putting together a bundle for an activity and sometimes my boolean
isLive
is null. When I do the following.
Bundle b = n开发者_运维知识库ew Bundle();
b.putBoolean("isLive", isLive);
The docs for the SDK clearly say both arguments are allowed to be null, however if isLive
is null I get a NullPointerException
have I found a bug in the SDK?
The second parameter to putBoolean is a boolean, not a Boolean. Autounboxing will try to call .booleanValue on the Boolean you're passing in, resulting in the NullPointerException. The documentation is incorrect, and in this case null values will definitely not work since the value parameter type is a primitive.
精彩评论