简体   繁体   English

Intent.getExtra提供nullPointerException

[英]Intent.getExtra gives nullPointerException

In one class I have this: 一堂课我有这个:

Double iso1 = 0.0;
final Intent start = new Intent(IsoAbun.this, IsoAbunCal.class);
start.putExtra("iso1", iso1);
startActivity(start);

Then in the other class I have this: 然后在另一个班级我有这个:

Bundle b = getIntent().getExtras();
Double iiso1 = 0.0;
iiso1 = Double.parseDouble(b.getString("iso1"));

All that gives a nullPointerException. 所有这些都给出了nullPointerException。 The code seems fine to me, so is there anything I am missing, or is more information required? 该代码对我来说似乎很好,所以我缺少什么,还是需要更多信息?

try b.getDouble(key) 试试b.getDouble(key)

hope it helps :) 希望能帮助到你 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM