How can I send a Map<String,Integer>= new HashMap<>();
from one activity to another, using Intent
?
How can I send a Map<String,Integer>= new HashMap<>();
from one activity to another, using Intent
?
It is similar to how it is done with another type of data:
Map<String,Integer> hashMap = new HashMap<String, Integer>();
Intent intent = new Intent(this, OtraActivity.class);
intent.putExtra("hashmap", hashMap);
startActivity(intent);
upon receipt of the Bundle
in another Activity
would be:
Intent intent = getIntent();
Map<String,Integer> hashMap = (Map<String, Integer>)intent.getSerializableExtra("hashmap");