2012-02-16 67 views
7

我“米创造了一个活动捆绑,然后在另一个活动创建包发送到新的活动

这里提取它,当它在他主Activity的创建

//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"); 

当我提取束的第二个活动。 但应用程序崩溃时我注释掉BU的提取ndle。该应用程序运行良好。所以我把它缩小到了这个范围。

我的日志猫并没有真正解释错误是什么,或者我只是不明白它

想法?

+0

简单的问题致电startActivity(myIntent);

//Add the bundle into myIntent for referencing variables myIntent.putExtras(bundle); 

将这个。开始新活动后,您正在调用putExtras(包)。 – 2013-08-09 15:39:10

回答

3

你加入以下代码后,之前startActivity(myIntent);