Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7014255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:29:51+00:00 2026-05-27T22:29:51+00:00

I have the class that implements Parcelable interface. That contain HashMap , this HashMap

  • 0

I have the class that implements Parcelable interface. That contain HashMap, this HashMap contains bitmap images. I need this HashMap for all my activities. So I used Parcelable. Look on my Parcelable code.

private HashMap<String, Bitmap> map;

        public ParcelFullData() {
            map = new HashMap();
        }

        public ParcelFullData(Parcel in) {
            map = new HashMap();
            readFromParcel(in);
        }

        public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
            public ParcelFullData createFromParcel(Parcel in) {
                return new ParcelFullData(in);
            }

            public ParcelFullData[] newArray(int size) {
                return new ParcelFullData[size];
            }
        };

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(map.size());
            for (String s: map.keySet()) {
                dest.writeString(s);
                dest.writeValue(map.get(s));
            }
        }

        public void readFromParcel(Parcel in) {
            int count = in.readInt();
            for (int i = 0; i < count; i++) {
                map.put(in.readString(), (Bitmap)in.readValue(Bitmap.class.getClassLoader()));
            }
        }

        public Bitmap get(String key) {
            return map.get(key);
        }

        public String[] getKeys() {
            Set<String> mapset = map.keySet();
            String[] photoName = new String[mapset.size()];
            Iterator<String> itr = mapset.iterator();
            int index = 0;
            while (itr.hasNext()) {
                String name = itr.next();
                photoName[index] = name;
                index++;
            }
            return photoName;
        }

        public void put(String key, Bitmap value) {
            map.put(key, value);
        }

        public HashMap<String, Bitmap> getHashMap() {
            return map;
        }

This will working fine when i pass the one Activity to another Activity.( For example Activity A to Activity B.) But If I pass this to another Activity( For example Activity B to Activity C.) means that HashMap contains no elements. That size is 0.

In Activity_A,

Intent setIntent = new Intent(activity_a, Activity_B.class);

ParcelFullData parcelData = new ParcelFullData();

Bundle b = new Bundle();
b.putParcelable("parcelData", parcelData);
startActivity(setIntent);

In Activity_B

ParcelFullData parcelData = (ParcelFullData)bundle.getParcelable("parcelData");

Parcel parcel = Parcel.obtain();
parcel.writeParcelable(parcelData , 0);
parcelData.writeToParcel(parcel, 0);
Intent setIntent = new Intent(activity_a, Activity_B.class);
Bundle b = new Bundle();
b.putParcelable("parcelData", parcelData);
startActivity(setIntent);

I’m doing the same in Activity C.

How to use resolve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:29:52+00:00Added an answer on May 27, 2026 at 10:29 pm

    Why do you use bundle? You don’t add this bundle to intent. Use Intent.putExtra(String, Parcelable) and everything will be OK. I pass one Parcelable object through all activities in my app and it works fine.

    In first activity:

    Intent i = new Intent(activity_a, Activity_B.class);
    i.putExtra("parcelData", parcelData);
    

    In second activity:

    parcelData = getIntent().getParcelableExtra("parcelData");
    // ... do anything with parcelData here
    Intent i = new Intent(activity_b, Activity_C.class);
    i.putExtra("parcelData", parcelData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a class that implements the IDisposable interface. Something like this:
I have a class that implements an interface like this; ... = new Location<ICafe>();
I have a class that implements java.io.Serializable interface.So all the variables in that class
I have a class that implements the IDisposable interface. I am using a webclient
Given: I have an interface. I have only class that implements that interface. Question:
I have a custom class that implements that IComparable. This class is stored in
I have a custom class that implements ICollection , and this class is readonly,
I have a class that implements an interface, and that interface extends another interface.
I have a class that implements an interface. The interface is public interface IRiskFactory
I have a class that implements an interface. In another area of the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.