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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:58:05+00:00 2026-06-09T09:58:05+00:00

I have to pass a ArrayList from one activity to another activity. So I

  • 0

I have to pass a ArrayList from one activity to another activity. So I use

intent.putParcelableArrayListExtra("Items",sendinglist);

And I get the sendinglist through

ArrayList<GeoItem> revd = new ArrayList<GeoItem>();
        Bundle b = getIntent().getExtras();
        if (b != null)
            revd = b.getParcelableArrayList("Items");
Log.i("Element details",revd.get(0).getLatitude()+"");// Error 

But i cant access the GeoItem object in that list.
UPDATE the class based on the answers…

My GeoItem class is

public class GeoItem implements Parcelable, Serializable {

/** id of item. */
protected long id_;
/** item location in GeoPoint. */
// protected GeoPoint location_;
/** selection state flag. true if selected. */
protected boolean isSelected_;
protected int latitude;
protected int longitude;
protected String incident_no;
protected String title;
protected String date;
protected String address;

/**
 * @param id
 *            item id.
 * @param latitudeE6
 *            latitude of the item in microdegrees (degrees * 1E6).
 * @param longitudeE6
 *            longitude of the item in microdegrees (degrees * 1E6).
 */
public GeoItem(long id, int latitudeE6, int longitudeE6, String inc_no,
        String tlt, String dates, String addr) {
    id_ = id;
    // location_ = new GeoPoint(latitudeE6, longitudeE6);
    isSelected_ = false;
    incident_no = inc_no;
    title = tlt;
    date = dates;
    address = addr;
    latitude=latitudeE6;
    longitude=longitudeE6;
}

public long getId_() {
    return id_;
}

public void setId_(long id_) {
    this.id_ = id_;
}

public String getTitle() {
    return title;
}

public void setTitle(String title) {
    this.title = title;
}

public String getDate() {
    return date;
}

public void setDate(String date) {
    this.date = date;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public void setIncident_no(String incident_no) {
    this.incident_no = incident_no;
}

public int getLatitude() {
    return latitude;
}

public void setLatitude(int latitude) {
    this.latitude = latitude;
}

public int getLongitude() {
    return longitude;
}

public void setLongitude(int longitude) {
    this.longitude = longitude;
}

/**
 * @param src
 *            source GeoItem
 */
public GeoItem(GeoItem src) {
    id_ = src.id_;
    // location_ = new
    // GeoPoint(src.location_.getLatitudeE6(),src.location_.getLongitudeE6());
    isSelected_ = src.isSelected_;
}

/**
 * @param src
 *            source Parcel
 */
public GeoItem(Parcel src) {
    id_ = src.readLong();
    // location_ = new GeoPoint(src.readInt(), src.readInt());
    isSelected_ = src.readInt() == 0 ? false : true;
    address = src.readString();
    date = src.readString();
}

/* describeContents */
public int describeContents() {
    return 0;
}

/**
 * getId
 * 
 * @return id of the item.
 */
public long getId() {
    return id_;
}

public String getIncident_no() {
    return incident_no;
}

/**
 * setId
 * 
 * @param id
 *            of the item.
 */
public void setId(long id) {
    id_ = id;
    ;
}

/**
 * getLocation
 * 
 * @return GeoPoint of the item.
 * 
 *         public GeoPoint getLocation() { return location_; }
 */
/**
 * isSelected
 * 
 * @return true if the item is in selected state.
 */
public boolean isSelected() {
    return isSelected_;
}

/**
 * setSelect
 * 
 * @param flg
 *            flag to be set.
 */
public void setSelect(boolean flg) {
    isSelected_ = flg;
}

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

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

/**
 * writeToParcel
 * 
 * @param parcel
 *            Parcel to be written.
 * @param flags
 *            flag.
 */
public void writeToParcel(Parcel parcel, int flags) {
    parcel.writeLong(id_);
    parcel.writeString(address);
    parcel.writeString(date);
    parcel.writeInt(latitude);
    parcel.writeInt(longitude);
    int flg = isSelected_ ? 1 : 0;
    parcel.writeInt(flg);
}


}

Please provide me the best way…

  • 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-09T09:58:06+00:00Added an answer on June 9, 2026 at 9:58 am

    My actual task is to send the list of GeoItems object through intent. Also My GeoItems class is serializable . Obviously list of serializable object is also serialibale So I used,

    Intent listview = new Intent(context, ReportList.class);
                Bundle send = new Bundle();
                send.putSerializable("Items", (Serializable) items);
                listview.putExtras(send);
                context.startActivity(listview);
    

    where items is a list of GeoIems objects

    And in receiving activity,

     Bundle b = this.getIntent().getExtras();
            if (b != null) {
                data = (List<GeoItem>) b.getSerializable("Items");
            }
    

    where data is a list of GeoIems objects

    Without using Parceable interface, now i can set my list of serializable objects through intent to next activity

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

Sidebar

Related Questions

I want to pass a custom object from one Activity to another, here is
I know how to pass a variable from one activity to another using global
I have two activity and I want to pass ArrayList -> drawablesFromUrl objs from
Bit of a weird question. I'm passing data from one activity to another -
I am using XML parser.In that i have to pass one id from one
I am having a problem in trying to pass a ArrayList Object from Activity
I have to pass back information from a different source and can have a
I have to pass information from a desktop application to Web application and vice
I m using one EditText field and one spinner. I have to pass teh
I understand that there's a set of methods used to pass data from one

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.