2012-02-16 21 views
7

मैं "एक गतिविधि में एक बंडल बनाने मीटर से अधिक भेजने, फिर एक और गतिविधिबंडल बनाने और नई गतिविधि

यहाँ

में यह निकालने जब यह

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

अनुप्रयोग क्रैश हो जाता है जब मैं दूसरी गतिविधि पर बंडल निकालने कर रहा हूँ। लेकिन जब मैं बू की निकासी के बाहर टिप्पणी ndle। ऐप ठीक चलाता है। तो मैंने इसे नीचे संकुचित कर दिया है।

मेरे लॉग बिल्ली वास्तव में स्पष्ट नहीं होता क्या त्रुटि है, या मैं सिर्फ यह

विचारों को समझने न?

+0

आसान सवाल से पहले startActivity(myIntent);

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

इस रखो बुला के बाद। आप नई गतिविधि शुरू करने के बाद putExtras (बंडल) को बुला रहे हैं। –

उत्तर

3

आप नीचे दिए गए कोड को जोड़ रहे हैं सिर्फ startActivity(myIntent);

संबंधित मुद्दे