java - Some parcelables objects put together in an Intent/bundle could be interfere themselves and to compromise the read of Intent/Bundle? -
some parcelables objects put in intent/bundle interfere , compromise read of intent/bundle?
i extract code where, think, there problem. code works:
public void writetoparcel(parcel arg0, int arg1) { arg0.writeparcelable(object1, arg1); arg0.writetypedlist(arraylist1); } public void readfromparcel(parcel in) { object1 = in.readparcelable(object1.class.getclassloader()); arraylist1 = new arraylist<object3>(); in.readtypedlist(arraylist1, object3.creator); }
but if add other complex parcelable object (with intern parcelable arraylist):
public void writetoparcel(parcel arg0, int arg1) { arg0.writeparcelable(object1, arg1); arg0.writeparcelable(object2, arg1); arg0.writetypedlist(arraylist1); } public void readfromparcel(parcel in) { object1 = in.readparcelable(object1.class.getclassloader()); object2 = in.readparcelable(object2.class.getclassloader()); arraylist1 = new arraylist<object3>(); in.readtypedlist(arraylist1, object3.creator); }
i obtain boucle more 10000000 elements arraylist1 (or others issues incomprehensible)
although if delete lines arraylist1, works:
public void writetoparcel(parcel arg0, int arg1) { arg0.writeparcelable(this.object1, arg1); arg0.writeparcelable(this.object2, arg1); } public void readfromparcel(parcel in) { object1 = in.readparcelable(object1.class.getclassloader()); object2 = in.readparcelable(object2.class.getclassloader()); }
i tried make object extends arraylist , implements parcelable have others issues (as android.os.badparcelableexception: classnotfoundexception when unmarshalling:)
if these object interfere themselves, have use several bundles tu put these different objects same intent?
i think had same problem 1 day. far can remember, fixed writing/reading parcelable after other types. like:
public void writetoparcel(parcel arg0, int arg1) { arg0.writetypedlist(arraylist1); arg0.writeparcelable(object1, arg1); arg0.writeparcelable(object2, arg1); } public void readfromparcel(parcel in) { arraylist1 = new arraylist<object3>(); in.readtypedlist(arraylist1, object3.creator); object1 = in.readparcelable(object1.class.getclassloader()); object2 = in.readparcelable(object2.class.getclassloader()); }
(haven't tried code though)
Comments
Post a Comment