【发布时间】:2012-06-12 11:27:37
【问题描述】:
我想将int[] 放入 Android Intent 中。由于各种原因,我收到了LinkedList<Integer>,所以我(大致)尝试了这个:
LinkedList<Integer> myList = getIntegerList();
Intent intent = new Intent (context, class);
intent.putExtra("com.me.INTARRAY", myList.toArray());
这不起作用,因为toArray() 给了我一个Object[]。我以为我可以通过这样做来解决它
intent.putExtra("com.me.INTARRAY", (Integer[]) myList.toArray(new Integer[myList.size()]) )
确实会产生Integer[];但是,将其从 Intent 中取出仍然不起作用。
最终,使用for 循环解决这个问题并不太难,所以我比任何其他原因都更加好奇,但是......你如何让Integer[] 额外成为Intent是int[]?
【问题讨论】:
标签: android arrays android-intent extra