-- Problem Solved --
I want to send an object present in my "Activity1" to my "Activity2". To do that, i'm using Parcelable.
I have a class User which implements Parcelable.
In my first activity, i create a user (for test), like this :
User userTest = new User("Name", "FirstName", "AdressTest", 1, "99999", "Nice guy", "pic.jpg",null);
And i call the next activity with that :
Intent intent = new Intent(
MainActivity.this,
UserProfile.class
);
intent.putExtra("userParce", userTest);
startActivity(intent);
The problem is, when i want to show the data of this user in my Activity2, i do that :
Intent intent = getIntent();
User user_current = intent.getExtras().getParcelable("userParce");
Log.i("User Name", user_current.getName());
Log.i("User FirstName", user_current.getFirstName());
Log.i("User Adress", user_current.getAdress());
etc...
The problem is that ONLY the "Name" and the Firstname are showing, others are "null", and i don't understand why :'(
Someone to help me ?
PS :
I don't show all the code, because it's useless, with that, there is just a constructor, and my getters.
@Override
public int describeContents()
{
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags)
{
dest.writeString(name);
dest.writeString(firstName);
dest.writeString(adress);
dest.writeInt(numberTest);
dest.writeString(code);
dest.writeString(description);
dest.writeString(image);
dest.writeList(listObject);
}
public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>()
{
@Override
public UsercreateFromParcel(Parcel source)
{
return new User(source);
}
@Override
public User[] newArray(int size)
{
return new User[size];
}
};
public static Parcelable.Creator<User> getCreator()
{
return CREATOR;
}
public User(Parcel in) {
this.name= in.readString();
this.firstName= in.readString();
this.numberTest= in.readInt();
this.code = in.readString();
this.description = in.readString();
this.image = in.readString();
this.listObject = null;
}