<分区>
我的一个 Activity 中有一个 HashMap(String,HashMap(String,Object))。如何通过 intents 将此 HashMap 发送到另一个 Activity
如何将这个HashMap添加到intent extras中?
<分区>
我的一个 Activity 中有一个 HashMap(String,HashMap(String,Object))。如何通过 intents 将此 HashMap 发送到另一个 Activity
如何将这个HashMap添加到intent extras中?
最佳答案
发送HashMap
HashMap<String, Object> hashmapobject =new HashMap<>();
HashMap<String, Object> newhashMap=new HashMap<>();
hashmapobject.put("key",newhashMap);
Intent intent = new Intent(SenderActivity.this, NextActivity.class);
intent.putExtra("hashMapKey", hashmapobject);
startActivity(intent);
接收HashMap
Intent intent = getIntent();
HashMap<String, Object> hashMapObject = (HashMap<String, Object>) intent.getSerializableExtra("hashMapKey");
HashMap<String, Object> newhashMap=(HashMap<String, Object>)hashMapObject.get("key");
关于android - 通过 android intents 传递 Hashmap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38685151/