Android HashMap in Bundle?

android, bundle, dictionary

Solution

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`

Problem

The `android.os.Message` uses a `Bundle` to send with it's sendMessage-method. Therefore, is it possible to put a `HashMap` inside a `Bundle`?

Original source

Related problems