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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:44:26+00:00 2026-06-15T09:44:26+00:00

I am trying to pass an ArrayList of objects through an intent but cannot

  • 0

I am trying to pass an ArrayList of objects through an intent but cannot get it to work. Here is what I have:

public class QuestionView extends Activity {

    //variables and other methods...

    public void endQuiz() {
        Intent intent = new Intent(QuestionView.this, Results.class);
        intent.putExtra("correctAnswers", correctAnswers);
        intent.putExtra("wrongAnswers", wrongAnswers);
        intent.putParcelableArrayListExtra("queries", queries);
        startActivity(intent);
    }
}

Intents are being received here:

public class Results extends Activity {

    int cAnswers;
    int wAnswers;
    ArrayList<Question> qs;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.resultsmain);

        cAnswers = getIntent().getIntExtra("correctAnswers", -1);
        wAnswers = getIntent().getIntExtra("wrongAnswers", -1);

        qs = getIntent().getParcelableArrayListExtra("queries");

                    //more code...
    }
}

The two ints, correctAnswer and wrongAnswers, are being received and I can use them. The ArrrayList is not coming through. No errors on in the endQuiz() method but the ‘qs = getIntent().getParcelableArrayListExtra(“queries”);’ is throwing an error and saying “Bound Mismatch.”

Any help on this is appreciated!

Question class:

public class Question {
    String a1;
    String a2;
    String a3;
    String a4;
    int correctAnswer;
    String query;
    int selectedAnswer;
    boolean correctness;

    public Question() {
    }

    public Question(String a1, String a2, String a3, String a4, int correctAnswer, String query, int selectedAnswer, boolean correctness) {
        this.a1 = a1;
        this.a2 = a2;
        this.a3 = a3;
        this.a4 = a4;
        this.correctAnswer = correctAnswer;
        this.query = query;
        this.selectedAnswer = selectedAnswer;
        this.correctness = correctness;
    }
    }
  • 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-15T09:44:27+00:00Added an answer on June 15, 2026 at 9:44 am

    You must change your Question class to actually implement Parcelable. The Parcelable interface can be confusing at first… but hang in there.

    There are two Parcelable methods that you should focus on:

    • writeToParcel() which converts your class into a Parcel object.
    • Question(Parcel in) which converts a Parcel object back into usable instance of your class.

    You can safely cut & paste the other Parcelable information that I marked.

    For the sake of simplicity I will only use part of your Question class:

    public class Question implements Parcelable {
        String a1;
        String a2;
        ...
    
        public Question(String a1, String a1) {
            this.a1 = a1;
            this.a2 = a2;
        }
    
        // Your existing methods go here. (There is no need for me to re-write them.) 
    
        // The following methods that are required for using Parcelable
        private Question(Parcel in) {
            // This order must match the order in writeToParcel()
            a1 = in.readString();
            a2 = in.readString();
            // Continue doing this for the rest of your member data
        }
    
        public void writeToParcel(Parcel out, int flags) {
            // Again this order must match the Question(Parcel) constructor
            out.writeString(a1);
            out.writeString(a2);
            // Again continue doing this for the rest of your member data
        }
    
        // Just cut and paste this for now
        public int describeContents() {
            return 0;
        }
    
        // Just cut and paste this for now
        public static final Parcelable.Creator<Question> CREATOR = new Parcelable.Creator<Question>() {
            public Question createFromParcel(Parcel in) {
                return new Question(in);
            }
    
            public Question[] newArray(int size) {
                return new Question[size];
            }
        };
    }
    

    Now change how you put queries into your Intent extras.

    intent.putParcelableArrayListExtra("queries", queries);
    

    The way you read the Parcelable array is perfect as it is.

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

Sidebar

Related Questions

I am trying pass class as value in hashmap. I need to get the
i am trying to pass an arraylist back to my parent activity Here is
Hi I am trying to pass my ArrayList value into my TabLayout but I
I'm trying to pass an ArrayList of Parcelable objects plus a string value between
I have a class that contains two arraylists which I'm trying to store objects
I am trying to pass an ArrayList of Objects from one action to another.
Hi Im trying to pass an arraylist to a prepared statement but am getting
I'm trying to pass an ArrayList iterator to a JSP from a Spring class,
I'm trying to pass KEY_THUMB_URL to SingleMenuItemActivity.class to show Image onclick listview. I have
I have an AsyncTask inside an Service which is trying to pass a ArrayList

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.