so I am getting this in logcat:
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.resources.student_list.Student)
I know this means that my student class is not serializable, but it is, here is my student class:
import java.io.Serializable;
public class Student implements Comparable<Student>, Serializable{
private static final long serialVersionUID = 1L;
private String firstName, lastName;
private DSLL<Grade> gradeList;
public Student() {
firstName = "";
lastName = "";
gradeList = new DSLL<Grade>();
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public DSLL<Grade> getGradeList() {
return gradeList;
}
public void setGradeList(DSLL<Grade> gradeList) {
this.gradeList = gradeList;
}
public int compareTo(Student arg0) {
return this.lastName.compareTo(arg0.getLastName());
}
}
and this is the code that is using the getIntent() method:
public void onItemClick(AdapterView<?> parent, View viewClicked, int pos,
long id) {
Student clickedStudent = studentList.get(pos);
int position = pos;
Intent intent = new Intent(getActivity().getApplicationContext(), ShowStudentActivity.class);
Log.e("CINTENT","CREATED!!!");
intent.putExtra("clickedStudent",clickedStudent);
intent.putExtra("newStudentList",newStudentList);
intent.putExtra("position",position);
Log.e("putExtra","Passed");
Log.e("Start activity","passed");
startActivity(intent);
}
});
please help me figure out whats wrong with this.
here is the whole LogCat:
04-17 16:12:28.890: E/AndroidRuntime(22815): FATAL EXCEPTION: main
04-17 16:12:28.890: E/AndroidRuntime(22815): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.resources.student_list.Student)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Parcel.writeSerializable(Parcel.java:1181)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Parcel.writeValue(Parcel.java:1135)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Parcel.writeMapInternal(Parcel.java:493)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Bundle.writeToParcel(Bundle.java:1612)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Parcel.writeBundle(Parcel.java:507)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.content.Intent.writeToParcel(Intent.java:6111)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1613)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1422)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.app.Activity.startActivityForResult(Activity.java:3191)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:848)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.support.v4.app.Fragment.startActivity(Fragment.java:878)
04-17 16:12:28.890: E/AndroidRuntime(22815): at com.example.student_lists.MainActivity$DummySectionFragment$2.onItemClick(MainActivity.java:477)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.widget.AbsListView$1.run(AbsListView.java:3168)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Handler.handleCallback(Handler.java:605)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Looper.loop(Looper.java:137)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.app.ActivityThread.main(ActivityThread.java:4447)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 16:12:28.890: E/AndroidRuntime(22815): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-17 16:12:28.890: E/AndroidRuntime(22815): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-17 16:12:28.890: E/AndroidRuntime(22815): at dalvik.system.NativeStart.main(Native Method)
04-17 16:12:28.890: E/AndroidRuntime(22815): Caused by: java.io.NotSerializableException: com.resources.student_list.DSLL$DNode
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1364)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
04-17 16:12:28.890: E/AndroidRuntime(22815): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
04-17 16:12:28.890: E/AndroidRuntime(22815): at android.os.Parcel.writeSerializable(Parcel.java:1176)
the Grade class must also implement Serializable