You cannot reliably send a LinkedHashMap
as an Intent
extra. When you call putExtra()
with a LinkedHashMap
, Android sees that the object implements the Map
interface, so it serializes the name/value pairs into the extras Bundle
in the Intent
. When you want to extract it on the other side, what you get is a HashMap
, not a LinkedHashMap
. Unfortunately, this HashMap
that you get has lost the ordering that was the reason you wanted to use a LinkedHashMap
in the first place.
The only reliable way to do this is to convert the LinkedHashMap
to an ordered array, put the array into the Intent
, extract the array from the Intent
on the receiving end, and then recreate the LinkedHashMap
.
See my answer to this question for more gory details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…