Ramosaurio Asked: 2020-08-11 13:26:55 +0800 CST 2020-08-11 13:26:55 +0800 CST 2020-08-11 13:26:55 +0800 CST How to send HashMap<String,Integer> with Intent to another Activity 772 How can I send a Map<String,Integer>= new HashMap<>();from one activity to another, using Intent? android 1 Answers Voted Best Answer Jorgesys 2020-08-11T13:43:53+08:002020-08-11T13:43:53+08:00 It is similar to how it is done with other data types: Map<String,Integer> hashMap = new HashMap<String, Integer>(); Intent intent = new Intent(this, OtraActivity.class); intent.putExtra("hashmap", hashMap); startActivity(intent); when receiving it Bundlein another it Activitywould be: Intent intent = getIntent(); Map<String,Integer> hashMap = (Map<String, Integer>)intent.getSerializableExtra("hashmap");
It is similar to how it is done with other data types:
when receiving it
Bundle
in another itActivity
would be: