I have a custom object class but that is implemented through an inteface, how can i incorporate parceable in it. I have followed and searched about parceable, but it is only for object class. eg : How can I make my custom objects Parcelable?
I want to pass my object list to another activity in android.
code :
public interface Projection {
interface Job {
@XBRead("./task")
List<Task> getTasks();
@XBRead("./id")
String getid();
@XBRead("./job_title")
String getjob_title();
@XBRead("./job_description")
String getjob_description();
@XBRead("./job_room")
String getjob_room();
@XBRead("./status")
String getstatus();
}
interface Task {
@XBRead("./task_id")
String gettask_id();
@XBRead("./task_title")
String gettask_title();
@XBRead("./task_description")
String gettask_description();
@XBRead("./task_status")
String gettask_status();
}
@XBRead("/root/job")
List<Job> getJobs();
}
Your custom interfaces need to extend Parcelable
.
Classes that implement your custom interface need to also implement the Parcelable
interface, including the CREATOR
.
You can then add an object implementing your custom interface to an Intent
like this:
intent.putExtra("thing", thing);
or add an ArrayList
containing these objects like this:
ArrayList<Thing> things;
intent.putParcelableArrayListExtra("things", things);
On the receiving end, the Activity
can extract the objects from the Intent
like this:
Thing thing = intent.getParcelableExtra("thing");
or
ArrayList<Thing> things = intent.getParcelableArrayListExtra("things");