Unmarshalling unknown type code (settings)

Source: Internet
Author: User

Android | unmarshalling unknown type while using parcelable data in bundles
Arraylist <model> mmodellist = new arraylist <model>
// Fill arraylist with a few model-objects

Bundle mbundle = new bundle;
Intent mintent = new intent (aaaa. This, BBBB. Class );

Mbundle. putparcelablearraylist ("models", mmodellist );
Mintent. putextras (mbundle );

Startactivity (mintent );

Bundle mbundle = getintent (). getextras ();
Arraylist <model> = mbundle. getparcelablearraylist ("models ");

Error/androidruntime (11109): Fatal exception: Main
Java. lang. runtimeexception: unable to start activity componentinfo {test/test. activities. bbbb}: Java. lang. runtimeexception: parcel android. OS. parcel @ 405585d0: unrecoverable alling unknown type code 7667810 at offset 144
At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 1651)
At Android. App. activitythread. handlelaunchactivity (activitythread. Java: 1667)
At Android. App. activitythread. Access $1500 (activitythread. Java: 117)
At Android. App. activitythread $ H. handlemessage (activitythread. Java: 935)
At Android. OS. handler. dispatchmessage (handler. Java: 99)
At Android. OS. lorule. Loop (lorule. Java: 123)
At Android. App. activitythread. Main (activitythread. Java: 3687)
At java. Lang. Reflect. method. invokenative (native method)
At java. Lang. Reflect. method. Invoke (method. Java: 507)
At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 842)
At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 600)
At Dalvik. system. nativestart. Main (native method)
Caused by: Java. Lang. runtimeexception: parcel Android. OS. Parcel @ 405585d0: unmarshalling unknown type code 7667810 at offset 144
At Android. OS. Parcel. readvalue (parcel. Java: 1913)
At Android. OS. Parcel. readlistinternal (parcel. Java: 2092)
At Android. Operating. Parcel. readarraylist (parcel. Java: 1536)
At Android. OS. Parcel. readvalue (parcel. Java: 1867)
At Android. OS. Parcel. readmapinternal (parcel. Java: 2083)
At Android. OS. Bundle. unparcel (bundle. Java: 208)
At Android. OS. Bundle. getparcelablearraylist (bundle. Java: 1144)
At test. Activities. Bbbb. oncreate (Bbbb. Java: 52)
At Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1047)
At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 1615)
... 11 more

Arraylist <model> = mbundle. getparcelablearraylist ("models ");

Public class model implements parceleble {

Private string name;
Private string address;

Public Model (parcel ){
}
Public Model (){
}
Public Model (string name, string address ){
This. Name = Name;
This. Address = address;
}

// Getter and setter

// Equals, hashcode, tostring (autogenerated from idea)

@ Override
Public void writetoparcel (parcel, int I ){
Parcel. writestring (name );
Parcel. writestring (Address );
}

Public void readfromparcel (parcel ){
This. Name = parcel. readstring ();
This. Address = parcel. readstring ();
}

Public static parcelable. creator <model> creator = new parcelable. creator <model> (){
@ Override
Public Model createfromparcel (parcel ){
Return new model (parcel );
}

@ Override
Public Model [] new array (INT size ){
Return new model [size]
}
};
}

......

// ================================== Parcelable ======================= ===
Public int describecontents (){
Return 0;
}

Public void writetoparcel (parcel out, int flags ){
Parcel. writestring (name );
Parcel. writestring (Address );
}

Private model (parcel in ){
Name = in. readstring ();
Address = in. readstring ();
}

Public static final parcelable. creator <model> creator = new parcelable. creator <model> (){
Public Model createfromparcel (parcel in ){
Return new model (in );
}

Public Model [] newarray (INT size ){
Return new model [size];
}
};

......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.