I've been running into difficulties while trying to implement Parcelable to a number of my objects. So far I have a Project class with all of the String and integer variables and another object called ParcelableProject which contains a single Project class. My difficulty starts when I tried creating another Parcelable class by the name of AllProjects, this class contains a single array list which is made up of ParcelableProject objects.
I have this method by which I move Projects through intent:
public void addProject(ParcelableProject p){
Intent i = new Intent(this.getActivity(), ProjectsFragment.class);
ArrayList<ParcelableProject> data = new ArrayList<ParcelableProject>();
data.add(p);
i.putParcelableArrayListExtra("projects", data);
}
Furthermore, in my ProjectsFragment I try to access this ArrayList data via:
Intent i = getActivity().getIntent();
Bundle data=i.getExtras();
ArrayList Projects= data.getParcelable("projects");
ParcelableProject pProj=Projects.get(0);
But it gives me a "cannot convert from Object to ParcelableProject" error. What is the proper way to access my Project's variables? There is going to be a list of them passed into my ProjectsFragment so the Parcelable needs to contain an ArrayList of Projects, I just don't know how to access the individual ones.