Bundle Bundle = new Bundle();
Bundle.putInt("1s",0);
intent.putExtra("b",Bundle);
startActivity(intent);
Activity B: Intent intent = this.getIntent();
intent.getBundleExtra("b").getInt("1s")//报错:nullpointer
解释: api:
getExtras()the
map of all extras previously added with putExtra(), or null if none have been added.//a map of extended data?没懂。。那个英语好点的解释一下,(*^__^*)
嘻嘻……
putExtras(Intent src) Copy
all extras in 'src' in to this intent.
putExtras(Bundle extras)
Add a set of extended data to the intent.//因为是all,a set of,所以用Extras。。
putExtra(String name, Bundle value) Add
extended data to the intent.
Intent.getExtras()这个函数获得的Bundle是通过Intent.putExtra(.. , ..)这种函数放入的数值的Bundle,
而我是直接放的一个自己的Bundle进去
解决:putExtra("b",bundle)
getBundleExtra("name")//的到的Bundle就通过name与放进去的一一对应了。
意思就是说,intent里面的东西不只有Bundle,还有其他的?
同时,还要注意,你的intent是从什么地方来的。