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

  • Home
  • SEARCH
  • 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 9014123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:26:05+00:00 2026-06-16T03:26:05+00:00

I want to pass an array list of object(parcelable) to an intent in order

  • 0

I want to pass an array list of object(parcelable) to an intent in order to process it.
The arrayList contains 3 object and when i pass it to the next intent , the third object is loss and so i have a null pointer when i try to read through the list

telecharger.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

         recupParcours= new GetParcours(idLangue);
         recupParcours.start();
         try {
            recupParcours.join();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
         for(Parcours parcours: recupParcours.getListeParcours()) 
                System.out.println("Parcours: " + parcours);
         Intent intent = new Intent();
         intent.putParcelableArrayListExtra("listeParcoursADL",recupParcours.getListeParcours());

        intent.setClass(ChoiceLanguage.this,Test.class);

        startActivity(intent);


        }
    });

In logcat i can show

 12-14 13:53:00.395: I/System.out(10884): Parcours: com.dev.entity.Parcours@41d6f130
12-14 13:53:00.395: I/System.out(10884): Parcours: com.dev.entity.Parcours@41e05398
12-14 13:53:00.395: I/System.out(10884): Parcours: com.dev.entity.Parcours@41e07e00

In the test class now

public class Test extends Activity {
    @Override
    public void onCreate(Bundle icicle) {

        super.onCreate(icicle);
        setContentView(R.layout.download_parcours);
          ArrayList<Parcours>listeParcours= getIntent().getParcelableArrayListExtra("listeParcoursADL");
         for(Parcours parcours: listeParcours) 
            System.out.println("Parcours: " + parcours);
    }
}

I can show in the log:

    12-14 13:53:12.223: I/System.out(10884): Parcours: com.dev.entity.Parcours@41bf03e8
12-14 13:53:12.223: I/System.out(10884): Parcours: com.dev.entity.Parcours@41ba5310
12-14 13:53:12.223: I/System.out(10884): Parcours: null

I do not why the last object is skipped.
Moreover with this line :

 intent.putParcelableArrayListExtra("listeParcoursADL",recupParcours.getListeParcours());

The next intent take like 5 second before to be displayed and without it it’s instantaneous

Parcours code

package com.dev.entity;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;


public class Parcours  implements Parcelable{

 String parcours_lang_info_name;
 String parcours_lang_info_desc;
 int parcours_id;
 String parcours_image;
 int parcours_map;
 int parcours_realite_augmentee;
 int parcours_qrcode;
 int parcours_visite_manuelle;
 ArrayList<POI> listesPOI;
 public Parcours() {
    super();
    listesPOI= new ArrayList<POI>();
}



 public Parcours(String parcours_lang_info_name, String parcours_lang_info_desc,
        int parcours_id, String parcours_image, int parcours_map,
        ArrayList<POI> listesPOI, int parcours_realite_augmentee,
        int parcours_qrcode, int parcours_visite_manuelle) {
    super();
    this.parcours_lang_info_name = parcours_lang_info_name;
    this.parcours_lang_info_desc = parcours_lang_info_desc;
    this.parcours_id = parcours_id;
    this.parcours_image = parcours_image;
    this.parcours_map = parcours_map;
    this.listesPOI = listesPOI;
    this.parcours_realite_augmentee = parcours_realite_augmentee;
    this.parcours_qrcode = parcours_qrcode;
    this.parcours_visite_manuelle = parcours_visite_manuelle;
}

 public Parcours (Parcel in) {
        this();
        this.parcours_lang_info_name = in.readString();
        this.parcours_lang_info_desc = in.readString();
        this.parcours_id = in.readInt();
        this.parcours_image = in.readString();
        this.parcours_map = in.readInt();
        in.readTypedList(listesPOI,POI.CREATOR);
        this.parcours_realite_augmentee = in.readInt();
        this.parcours_qrcode = in.readInt();
        this.parcours_visite_manuelle = in.readInt();

    }

@Override
    public String toString() {

        /*return "parcours_lang_info_name: "+parcours_lang_info_name+" " + "parcours_lang_info_desc: "+parcours_lang_info_desc+" "
                +"parcours_id: " + parcours_id+" " +"parcours_image: "+parcours_image+" "+"parcours_map: "+parcours_map+" "+"parcours_realite_augmentee: "+ parcours_realite_augmentee+" "
                + "parcours_qrcode: "+ parcours_qrcode+" "+"parcours_visite_manuelle: "+parcours_visite_manuelle+" "+"listesPOI: "+listesPOI+" ";*/
    return super.toString();
    }

public String getParcours_lang_info_name() {
    return parcours_lang_info_name;
}
public void setParcours_lang_info_name(String parcours_lang_info_name) {
    this.parcours_lang_info_name = parcours_lang_info_name;
}
public String getParcours_lang_info_desc() {
    return parcours_lang_info_desc;
}
public void setParcours_lang_info_desc(String parcours_lang_info_desc) {
    this.parcours_lang_info_desc = parcours_lang_info_desc;
}
public int getParcours_id() {
    return parcours_id;
}
public void setParcours_id(int parcours_id) {
    this.parcours_id = parcours_id;
}
public String getParcours_image() {
    return parcours_image;
}
public void setParcours_image(String parcours_image) {
    this.parcours_image = parcours_image;
}
public int getParcours_map() {
    return parcours_map;
}
public void setParcours_map(int parcours_map) {
    this.parcours_map = parcours_map;
}
public int getParcours_realite_augmentee() {
    return parcours_realite_augmentee;
}
public void setParcours_realite_augmentee(int parcours_realite_augmentee) {
    this.parcours_realite_augmentee = parcours_realite_augmentee;
}
public int getParcours_qrcode() {
    return parcours_qrcode;
}
public void setParcours_qrcode(int parcours_qrcode) {
    this.parcours_qrcode = parcours_qrcode;
}
public int getParcours_visite_manuelle() {
    return parcours_visite_manuelle;
}
public void setParcours_visite_manuelle(int parcours_visite_manuelle) {
    this.parcours_visite_manuelle = parcours_visite_manuelle;
}

public ArrayList<POI> getPOI() {
    return listesPOI;
}

public void setPOI(ArrayList<POI> listesPOI) {
    this.listesPOI = listesPOI;
}



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

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




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



@Override
public void writeToParcel(Parcel dest, int flags) {

    dest.writeString(parcours_lang_info_name);
    dest.writeString(parcours_lang_info_desc);
    dest.writeInt(parcours_id);
    dest.writeString(parcours_image);
    dest.writeInt(parcours_map);

    dest.writeInt(parcours_realite_augmentee);
    dest.writeInt(parcours_qrcode);
    dest.writeInt(parcours_visite_manuelle);
    dest.writeTypedList(listesPOI);
}


}

Thank you very much

  • 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-16T03:26:06+00:00Added an answer on June 16, 2026 at 3:26 am

    You don’t write the parcel the same way you read it:

    in.readString();
    in.readString();
    in.readInt();
    in.readString();
    in.readInt();
    
    in.readTypedList(listesPOI,POI.CREATOR); <-- Mistmatch from here
    in.readInt();
    in.readInt();
    in.readInt();
    

    but

    dest.writeString();
    dest.writeString();
    dest.writeInt();
    dest.writeString();
    dest.writeInt();
    
    dest.writeInt(); <-- Mistmatch from here
    dest.writeInt();
    dest.writeInt();
    dest.writeTypedList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an arraylist called 'pri1', I want this array list to be available
I want to add the value like ArrayList<HashMap<String, Object>> to intent, and pass on
In my Delphi development, I want to pass an array of const(that can contains
I have an array of Ids that I want to pass to the entity
I want to pass a list array from the View to the controller on
I have an ArrayList of objects. ie ArrayList<ObjectName> . I want to pass this
Lets assume I have a list of objects in an array and i want
Basically what i want to do, is to pass a custom parcelable object via
i want to pass an array of objects i have stored in one for
I want to pass a delegate with the return type as ArrayList as parameter

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.