I tried to make an app that would display the periodic table and then you could click each element to take you to another screen to see its molar mass. From there you can go to another screen. The problem is that whenever I click on an element, instead of going to the next screen I get a runtime exception. This is printed in the stack trace. How do I solve the problem, I double checked that everything in the Element class which implements parcelable was done correctly
03-15 14:26:01.714: E/AndroidRuntime(11104): FATAL EXCEPTION: main
03-15 14:26:01.714: E/AndroidRuntime(11104): Process: com.example.androidhive, PID: 11104
03-15 14:26:01.714: E/AndroidRuntime(11104): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidhive/com.example.thecookieclub.Home}: java.lang.RuntimeException: Parcel android.os.Parcel@382eb178: Unmarshalling unknown type code 3014757 at offset 300
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.access$800(ActivityThread.java:144)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Handler.dispatchMessage(Handler.java:102)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Looper.loop(Looper.java:135)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.main(ActivityThread.java:5221)
03-15 14:26:01.714: E/AndroidRuntime(11104): at java.lang.reflect.Method.invoke(Native Method)
03-15 14:26:01.714: E/AndroidRuntime(11104): at java.lang.reflect.Method.invoke(Method.java:372)
03-15 14:26:01.714: E/AndroidRuntime(11104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
03-15 14:26:01.714: E/AndroidRuntime(11104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-15 14:26:01.714: E/AndroidRuntime(11104): Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@382eb178: Unmarshalling unknown type code 3014757 at offset 300
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readValue(Parcel.java:2222)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readListInternal(Parcel.java:2520)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readArrayList(Parcel.java:1836)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readValue(Parcel.java:2167)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.BaseBundle.unparcel(BaseBundle.java:221)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Bundle.getParcelableArrayList(Bundle.java:848)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.content.Intent.getParcelableArrayListExtra(Intent.java:4868)
03-15 14:26:01.714: E/AndroidRuntime(11104): at com.example.thecookieclub.Home.onCreate(Home.java:37)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.Activity.performCreate(Activity.java:5933)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
03-15 14:26:01.714: E/AndroidRuntime(11104): ... 10 more
Just in case I missed something, here is the class which implements Parcelable
public class Element implements Parcelable {
private double molarMass;
private String name;
private int ID;
private String symbol;
public Element (String elementName, int a, double mass, String sym){
name=elementName;
molarMass=mass;
ID= a;
symbol=sym;
}
public Element(Parcel in) {
name=in.readString();
symbol=in.readString();
ID=in.readInt();
molarMass=in.readDouble();
}
public String getName (){
return name;
}
public double getMass (){
return molarMass;
}
public int getID (){
return ID;
}
public String getSymbol (){
return symbol;
}
public static final Parcelable.Creator<Element> CREATOR
= new Parcelable.Creator<Element>() {
public Element createFromParcel(Parcel in) {
return new Element(in);
}
public Element[] newArray(int size) {
return new Element[size];
}
};
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString (name);
dest.writeInt (ID);
dest.writeDouble (molarMass);
dest.writeString (symbol);
}
/*public double calculate (double massInGrams){
double as=massInGrams/molarMass;
return as;
}*/
}