Alvaro Rojas
Alvaro Rojas

Reputation: 562

Android - Intent "putExtra"

I have the next code:

´
ArrayList<Integer> vc = new ArrayList<Integer>; vc.add(1); vc.add(2);
Intent myIntent = new Intent(class1.this, class2.class);
myIntent.putIntegerArrayListExtra("Key", vc);

´ the class2 receive correctly the arraylist, but... After I use the next code: (basically the same)

´
ArrayList<Integer> vc = new ArrayList<Integer>; vc.add(10); vc.add(20);
Intent myIntent = new Intent(class1.this, class2.class);
myIntent.putIntegerArrayListExtra("Key", vc);
´

My second class received again the first ArrayList with 1 and 2 values

Any idea?

Upvotes: 0

Views: 469

Answers (1)

luciferche
luciferche

Reputation: 134

I think the problem is that you are not instantiating arrayList ArrayList<Integer> vc = new ArrayList<Integer>(); so it is using old values

Upvotes: 1

Related Questions