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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:28:03+00:00 2026-05-25T20:28:03+00:00

I am trying to send an object of type MyCustomObject to another activity via

  • 0

I am trying to send an object of type MyCustomObject to another activity via an intent. I know, to make the class Parcelable, I should do public class MyCustomObject implements Parcelable, but I am not sure how custom object arrays work in parcelable. Here’s what I have got so far.. Also, do I need to make the Search class implements Parcelable too?

Here is my updated answer I now get a null object when I do intent.getParcelableExtra(search). Maybe I am not creating the search array properly?

public class MyCustomObject implements Parcelable{
    public Search search[];

    public MyCustomObject(Parcel in){
        in.readArray(MyCustomObject.class.getClassLoader());
    }

    @Override
    public int describeContents(){
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags){
        dest.writeArray(search)
    }

    public static final Parcelable.Creator<MyCustomObject> CREATOR = new Parcelable.Creator<MyCustomObject>(){
        @Override
        public MyCustomObject createFromParcel(Parcel source){
            return new MyCustomObject(source);
        }

        @Override
        public MyCustomObject[] newArray(int size){
            return new MyCustomObject[size];
        }
    }

    public static class Search implements Parcelable{
        public int rank;
        public String title;
        public String[] imageURL;

        public Search(Parcel in){
            rank = in.readInt();
            title = in.readString();

            String[] url = new String[4];
            in.readStringArray(url);
            url = imageURL
        }

        @Override
        public int describeContents(){
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags){
            dest.writeInt(rank);
            dest.writeString(title);
            dest.writeStringArray(imageURL);
        }

        public static final Parcelable.Creator<Search> CREATOR = new Parcelable.Creator<Search>(){

        @Override
        public Search createFromParcel(Parcel source){
            return new Search(source);
        }

        @Override
        public Search[] newArray(int size){
            return new Search[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-05-25T20:28:04+00:00Added an answer on May 25, 2026 at 8:28 pm

    A couple of things. First, your Search object will need to implement Parcelable as well. Next, you need to create a static field called CREATOR that implements Parcelable.Creator<MyCustomObject>. This will have a method called createFromParcel that returns an instance of MyCustomObject. That is where you read data out of a parcel and create a new instance of MyCustomObject. This is essentially the opposite of writeToParcel. This all applies to Search as well since you must make it implement Parcelable. In summary:

    • Make Search implement Parcelable
    • Implement Search.writeToParcel
    • Create a static field in Search called CREATOR that implements Parcelable.Creator<Search>
    • Implement the createFromParcel method of Search.CREATOR
    • Create a static field in MyCustomObject called CREATOR that implements Parcelable.Creator<MyCustomObject>
    • Implement the createFromParcel method of MyCustomObject.CREATOR
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to send an Object via socket. its object Net public class
I'm trying to send an object of a custom class through my asmx webservice
Happy coding weekend to everyone!!!. I'm stuck trying to send a JSON object via
I'm trying to compile a project containing this method; public void Send<T>(object o) where
I'm trying to send JSON-object form MongoDB to page with ejs template engine. Here's
I'm trying to send an object from my ASP .NET C# MVC3 project to
I am trying to send an object across GWT RPC (GWT 2.4). The object
I'm trying to send an XMLHttpRequest object to my Rails server but the headers
I am trying to send a form to a PHP file via jQuery. The
I'm trying to send a complex object to my WebMethod in a aspx page

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.