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

  • SEARCH
  • Home
  • 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 8511425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:59:16+00:00 2026-06-11T03:59:16+00:00

I’d like to pass a custom Object from one activity to another, the Object

  • 0

I’d like to pass a custom Object from one activity to another, the Object consists of a String and a List of another custom Object which consists of an array of strings and an array of ints. I’ve read https://stackoverflow.com/a/2141166/830104, but then I’ve found this answer https://stackoverflow.com/a/7842273/830104. Which is better to use Bundle or Parcelable? What is the difference? When should I use this each?
Thanks for your replies,
Dan

  • 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-06-11T03:59:18+00:00Added an answer on June 11, 2026 at 3:59 am

    Parcelable and Bundle are not exclusive concepts; you can even deploy both on your app at a time.

    [1] Term Parcelable comes with Serialization concept in Java (and other high-level language such as C#, Python,…). It ensures that an object – which remains in RAM store – of such Parcelable class can be saved in file stream such as text or memory (offline status) then can be reconstructed to be used in program at runtime (online status).

    In an Android application, within 2 independent activities (exclusively running – one starts then other will have to stop):

    There will be NO pointer from current activity to refer to previous one and its members – because previous activity is stopped and cleared out form memory; so that to maintain object’s value passed to next activity (called from Intent) the object need to be parcelable (serializable).

    [2] While Bundle is normally the Android concept, denotes that a variable or group of variables. If look into lower level, it can be considered as HashMap with key-value pairs.

    Conclusion:

    • Bundle is to store many objects with related keys, it can save any object in native types, but it doesn’t know how to save a complex object (which contains an ArrayList for example)

    • Parcelable class is to ensure a complex instance of it can be serialized and de-serialized during runtime. This object can contains complex types such as ArrayList, HashMap, array, or struct,…

    [UPDATED] – Example:

    //Class without implementing Parcelable will cause error 
    //if passing though activities via Intent
    public class NoneParcelable
    {
        private ArrayList<String> nameList = new ArrayList<String>();
        public NoneParcelable()
        {
            nameList.add("abc");
            nameList.add("xyz");            
        }
    }
    
    //Parcelable Class's objects can be exchanged 
    public class GoodParcelable implements Parcelable
    {
        private ArrayList<String> nameList = new ArrayList<String>();
        public GoodParcelable()
        {
            nameList.add("Can");
            nameList.add("be parsed");          
        }
        @Override
        public int describeContents()
        {
            return 0;
        }
        @Override
        public void writeToParcel(Parcel dest, int flags)
        {
            // Serialize ArrayList name here            
        }
    }
    

    In source activity:

    NoneParcelable nonePcl = new NoneParcelable();
    GoodParcelable goodPcl = new GoodParcelable();
    int count = 100;
    
    Intent i = new Intent(...);
    i.putExtra("NONE_P",nonePcl);
    i.putExtra("GOOD_P",goodPcl);
    i.putExtra("COUNT", count);
    

    In destination activity:

    Intent i = getIntent();
    
    //this is BAD:
    NoneParcelable nP = (NoneParcelable)i.getExtra("NONE_P"); //BAD code
    
    //these are OK:
    int count = (int)i.getExtra("COUNT");//OK
    GoodParcelable myParcelableObject=(GoodParcelable)i.getParcelableExtra("GOOD_P");// OK
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
I used javascript for loading a picture on my website depending on which small
I want to count how many characters a certain string has in PHP, but

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.