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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:27:42+00:00 2026-06-15T19:27:42+00:00

I need to pass a custom Parcelable object to another activity as Extra I

  • 0

I need to pass a custom Parcelable object to another activity as Extra

I put the extra with this code

Car myCarObject=getCar();
ArrayList<Car> parcelableExtra = new ArrayList<Car>();
                parcelableExtra.add(myCarObject);

Intent details = new Intent(Start.this, DetailsCar.class);
                details.putExtra("Car", parcelableExtra);
                startActivity(details);

I try to load the extra with this code in the destination Intent

ArrayList<Car> parcelableExtra = new ArrayList<Car>();
        parcelableExtra = (ArrayList<Car>) getIntent().getExtras().getParcelable("Car");
        Car c=parcelableExtra.get(0);

But the app crashes with this error stack:

12-14 03:34:24.059: E/AndroidRuntime(16872): FATAL EXCEPTION: main
12-14 03:34:24.059: E/AndroidRuntime(16872): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app.com/my.app.com.DetailsCar}: java.lang.RuntimeException: Parcel android.os.Parcel@4051ac20: Unmarshalling unknown type code 5505097 at offset 3144
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Looper.loop(Looper.java:130)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.ActivityThread.main(ActivityThread.java:3687)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at java.lang.reflect.Method.invokeNative(Native Method)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at java.lang.reflect.Method.invoke(Method.java:507)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at dalvik.system.NativeStart.main(Native Method)
12-14 03:34:24.059: E/AndroidRuntime(16872): Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@4051ac20: Unmarshalling unknown type code 5505097 at offset 3144
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readValue(Parcel.java:1913)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readListInternal(Parcel.java:2092)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readArrayList(Parcel.java:1536)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at my.app.com.obj.Car.<init>(Car.java:361)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at my.app.com.obj.Car.<init>(Car.java:347)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at my.app.com.obj.Car$1.createFromParcel(Car.java:339)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at my.app.com.obj.Car$1.createFromParcel(Car.java:1)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readParcelable(Parcel.java:1981)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readValue(Parcel.java:1846)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readListInternal(Parcel.java:2092)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readArrayList(Parcel.java:1536)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readValue(Parcel.java:1867)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Parcel.readMapInternal(Parcel.java:2083)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Bundle.unparcel(Bundle.java:208)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.os.Bundle.getParcelable(Bundle.java:1100)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at my.app.com.DetailsCar.onCreate(DetailsCar.java:43)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-14 03:34:24.059: E/AndroidRuntime(16872):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
12-14 03:34:24.059: E/AndroidRuntime(16872):    ... 11 more

My Parcelable Car Object is this

public class Car implements Serializable, Parcelable {
    String description;
    String speed;
    String brake;
    String pro;

    public Car(String description, String speed, String brake,
            String pro) {
        super();
        this.description = description;
        this.speed = speed;
        this.brake = brake;
        this.pro = pro;
    }

    public Car() {

    }

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel arg0, int arg1) {
        arg0.writeString(description);
        arg0.writeString(speed);
        arg0.writeString(brake);
        arg0.writeString(pro);
    }

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

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

    private Car(Parcel in) {
        description = in.readString();
        speed = in.readString();
        brake = in.readString();
        pro = in.readString();
        in.readArrayList(String.class.getClassLoader());
    }

}

How could I fix this issue?
Any suggestion?

  • 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-15T19:27:44+00:00Added an answer on June 15, 2026 at 7:27 pm

    Let’s look at two key functions:

    @Override
    public void writeToParcel(Parcel arg0, int arg1) {
        arg0.writeString(description);
        arg0.writeString(speed);
        arg0.writeString(brake);
        arg0.writeString(pro);
    }
    
    
    private Car(Parcel in) {
        description = in.readString();
        speed = in.readString();
        brake = in.readString();
        pro = in.readString();
        in.readArrayList(String.class.getClassLoader());
    }
    

    Note that the first writes 4 variables to the Parcel, and the later reads 5. The system is crashing because there isn’t an ArrayList in the Parcel. Put an arrayList in, and you should be fine. Alternatively, you could just remove the read function, as it doesn’t even appear to be used (But I will allow for the possibility that more could be in your function than you included)

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

Sidebar

Related Questions

I need to pass Cursor object to another activity, what is the best way
I need to call a method and pass an object from my custom UITableViewClass
I need pass data (in this case just a single id) to a custom
I have a need to pass a custom object to a remote web service.
I've created a custom field type in Joomla and need to pass parameters to
I have an ASP control custom built and I need to pass a value
I need to pass an extra parameter :mobilejs => true from jQuery to a
I want to pass a custom made vector object containing data from background service
I am calling an Activity using an Intent , and I need to pass
I need to pass a dynamic value to a custom taglib. Eg. <ibe:I18N baseName=msg

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.