As an alternative to @Jave suggestions, if you really need a data structure like TreeMap , just use the appropriate constructor, which takes another map as the data source. So, on the receiving side ( Two ), do the following:
public class Two extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TreeMap<String, String> map = new TreeMap<String, String>((Map<String, String>) getIntent().getExtras().get("map")); } }
However, depending on your project, you probably don't need to worry about a specific Map implementation. So instead, you can just go to the Map interface:
public class Two extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Map<String, String> map = (Map<String, String>) getIntent().getExtras().get("map"); } }
Mh.
source share