Nouvel Travay Nouvel Travay - 1 year ago 644
Android Question

Convert Map to Bundle in android

Is there an easy way to convert a Map to a Bundle in android without explicit iteration?


Firebase returns a Map for Notification

. I need to pass the data to an intent. Formerly GCM gave me a bundle, so I didn't need to worry about this.

Answer Source

I guess a good old fashioned for loop is the easiest way:

    Bundle bundle = new Bundle();
    for (Map.Entry<String, String> entry : getData().entrySet()) {
        bundle.putString(entry.getKey(), entry.getValue());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download