开发者

bundle.putBoolean() bug?

I am putting together a bundle for an activity and sometimes my boolean isLiveis 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜