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 8752059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:09:37+00:00 2026-06-13T13:09:37+00:00

I’m trying to pass an ArrayList of Parcelable objects plus a string value between

  • 0

I’m trying to pass an ArrayList of Parcelable objects plus a string value between two activities. This is the code to add the data to the intent and pass it through:

Intent intent = new Intent(this, DisplayLotListActivity.class);
Bundle dataBundle = new Bundle();
dataBundle.putParcelableArrayList(DisplayLotListActivity.EXTRA_LOT_ARRAY, lotList);
dataBundle.putString(EXTRA_LOT_NUMBER, lotNumber);
intent.putExtra(DisplayLotListActivity.EXTRA_DATA, dataBundle);
startActivity(intent);

This is the code that I’m using to get the data out of the intent on the target activity:

Intent intent = getIntent();
Bundle dataBundle = intent.getBundleExtra(EXTRA_DATA);
lotList = dataBundle.getParcelableArrayList(EXTRA_LOT_ARRAY);
lotNumber = dataBundle.getString(LotInquiryActivity.EXTRA_LOT_NUMBER);

When I check the debugger the data structures look correct before the activity is called but when I get into the target activity the data structure has been corrupted. Specifically the ArrayList as 3 elements and it is still 3 elements in size but the second element is null. There is then an additional extra in the bundle which contains the missing element object with a null key. I have images of the debugger before and after but can’t put them in the post because of anti-spam rules.

Before: https://i.stack.imgur.com/vDipq.png
After: https://i.stack.imgur.com/JqbF7.png

Is there something I’m missing? This issue occurs whether I use a Bundle or add the ArrayList directly to the intent. This is being run on a Samsung Tab 2 running 4.0.3. This also occurs with a 4.0 emulator.

[Edit]
This is the Parcelable object being used (I’ve just left the getter and setter methods off the bottom)

public class Lot implements Parcelable{

private String lotn;

private String dsc1;
private String dsc2;
private String litm;
private long itm;
private String locn;
private String mcu;
private String uom1;
private String uom2;
private BigDecimal pqav;
private BigDecimal pqoh;
private BigDecimal sqoh;
private long vend;
private String rlot;
private String ldsc;
private String lots;
private String lot1;
private String lot2;
private String lot3;
private String lotsdsc;
private XMLGregorianCalendar mmej;
private XMLGregorianCalendar ohdj;

public Lot(){

}

public Lot(Parcel source){
    lotn = source.readString();
    dsc1 = source.readString();
    dsc2 = source.readString();
    litm = source.readString();
    locn = source.readString();
    mcu = source.readString();
    uom1 = source.readString();
    uom2 = source.readString();
    itm = source.readLong();
    pqav = new BigDecimal(source.readString());
    pqoh = new BigDecimal(source.readString());
    sqoh = new BigDecimal(source.readString());
    vend = source.readLong();
    rlot = source.readString();
    ldsc = source.readString();
    lots = source.readString();
    lot1 = source.readString();
    lot2 = source.readString();
    lot3 = source.readString();
    lotsdsc = source.readString();
    try{
        mmej = DatatypeFactory.newInstance().newXMLGregorianCalendar(source.readString());
    }catch (Exception exc){
        mmej = null;
    }
    try{
        ohdj = DatatypeFactory.newInstance().newXMLGregorianCalendar(source.readString());
    }catch (Exception exc){
        ohdj = null;
    }
}

public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(lotn);
    dest.writeString(dsc1);
    dest.writeString(dsc2);
    dest.writeString(litm);
    dest.writeString(locn);
    dest.writeString(mcu);
    dest.writeString(uom1);
    dest.writeString(uom2);
    dest.writeLong(itm);
    if(pqav != null){
        dest.writeString(pqav.toPlainString());
    } else {
        dest.writeString("0");
    }
    if(pqoh != null){
        dest.writeString(pqoh.toPlainString());
    } else {
        dest.writeString("0");
    }
    if(sqoh != null){
        dest.writeString(sqoh.toPlainString());
    } else {
        dest.writeString("0");
    }
    dest.writeLong(vend);
    dest.writeString(rlot);
    dest.writeString(ldsc);
    dest.writeString(lots);
    dest.writeString(lot1);
    dest.writeString(lot2);
    dest.writeString(lot3);
    dest.writeString(lotsdsc);
    if(mmej != null){
        dest.writeString(mmej.toXMLFormat());
    } else {
        dest.writeString("");
    }
    if(ohdj != null){
        dest.writeString(ohdj.toXMLFormat());
    } else {
        dest.writeString("");
    }
}

/**
 *
 */
public static final Parcelable.Creator<Lot> CREATOR
         = new Parcelable.Creator<Lot>() {
     public Lot createFromParcel(Parcel in) {
         return new Lot(in);
     }

     public Lot[] newArray(int size) {
         return new Lot[size];
     }
 };
  • 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-13T13:09:38+00:00Added an answer on June 13, 2026 at 1:09 pm

    OK, for anyone that comes back to this question there’s two problems that I found which I assume combined to cause this behavior. The issues all related to the Parcelable object I was using so thanks to Todd for at least pointing me in this direction.

    Firstly, I had a simple error where I had missed a readString() in my constructor of the Parcelable object. So basically I was writing out n elements and reading in n – 1 elements. The second issue is that Android does not implement the javax.xml.datatype library which means that XMLGregorianCalendar is not available. As I didn’t need the features of this class on the client side (there’s a Java Web Application that it talks to which does use it) I just converted over to a simple java.util.Date object instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.