我在一个活动中创建一个包,然后在另一个活动中提取它
这是它在主要活动中创建的时间
//Create bundle to reference values in next class Bundle bundle = new Bundle(); bundle.putInt("ODD",odd); bundle.putInt("EVEN",even); bundle.putInt("SMALL",small); bundle.putInt("BIG",big); //After all data has been entered and calculated,go to new page for results Intent myIntent = new Intent(); myIntent.setClass(getBaseContext(),Results.class); startActivity(myIntent); //Add the bundle into myIntent for referencing variables myIntent.putExtras(bundle);
然后,当我提取其他活动
//Extract the bundle from the intent to use variables Bundle bundle = getIntent().getExtras(); //Extract each value from the bundle for usage int odd = bundle.getInt("ODD"); int even = bundle.getInt("EVEN"); int big = bundle.getInt("BIG"); int small = bundle.getInt("SMALL");
当我在第二个活动中提取包时应用程序崩溃.
但是当我注释掉束的提取时.该应用运行正常.所以我把它缩小到了那个范围.
我的日志猫并没有真正解释错误是什么,或者我只是不明白它
想法?