Android HashMap in Bundle?

try as:

Bundle extras = new Bundle();
extras.putSerializable("HashMap",hashMap);
intent.putExtras(extras);

and in second Activity

Bundle bundle = this.getIntent().getExtras();

if(bundle != null) {
   hashMap = bundle.getSerializable("HashMap");
}

because Hashmap by default implements Serializable so you can pass it using putSerializable in Bundle and get in other activity using getSerializable

Leave a Comment