I want to put an int[]
into an Android Intent. For various reasons I am getting a LinkedList<Integer>
, so I tried (roughly) this:
LinkedList<Integer> myList = getIntegerList();
Intent intent = new Intent (context, class);
intent.putExtra("com.me.INTARRAY", myList.toArray());
This didn't work because toArray()
was giving me an Object[]
. I thought I could fix it by doing
intent.putExtra("com.me.INTARRAY", (Integer[]) myList.toArray(new Integer[myList.size()]) )
which does indeed produce an Integer[]
; however, getting it out of the Intent
STILL doesn't work.
Ultimately this isn't too hard to work around with a for
loop so I ask more for curiosity than any other reason, but ... how do you get an Integer[]
into an Intent
extra as though it were an int[]
?