mardi 5 mai 2015

android: intent passing null

I have to pass a string from an activity to another.

in Activiy1 i made:

String modello=nomiImmagini[position];
Intent nomeModello = new Intent(getApplicationContext(), Activity2.class);
nomeModello.putExtra("modello", modello);

where the value of array nomiImmagini[position] is not null, if i made a toast like

Toast.makeText(getApplicationContext(),
                "Selezionato " + nomiImmagini[position], Toast.LENGTH_SHORT).show();

it work correctly.

in activity2 i made:

String modello = getIntent().getStringExtra("modello");

but here the result is null!

how can i fix this? I'm a beginner in android and maybe I not understand the intent.

Thanks and sorry for my english...

Aucun commentaire:

Enregistrer un commentaire