2012-02-16 15 views
7

I "m la creazione di un pacchetto in un'attività, quindi l'estrazione in un'altra attivitàcreando fascio e l'invio verso nuove attività

qui è quando è creato in lui l'attività principale

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

Poi, quando ho estrarre il altra attività

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

l'applicazione si blocca quando sto estrazione del fascio sulla seconda attività. Ma quando io commento l'estrazione del bu ndle. L'app funziona bene. Quindi l'ho ristretto a quello.

mio registro gatto in realtà non spiega che cosa l'errore è, o io solo dont capire

idee?

+0

domanda facile. Stai chiamando putExtras (pacchetto) dopo aver avviato la nuova attività. –

risposta

3

Si sta aggiungendo il codice di seguito dopo aver chiamato startActivity(myIntent);

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

Mettere questo poco prima startActivity(myIntent);

Problemi correlati