parcelable

Sending Nested Parcelable with Intent

烂漫一生 提交于 2019-12-02 01:50:21
I am trying to send a Parcelable object which also contains another Parcelable object with Intent. However, I am getting NullPointer Exception. Could you please tell me where I am doing wrong? A.java public class A implements Parcelable { private ArrayList<B> var; public A() { this.var = new ArrayList<B>(); } public void addToB(B b) { var.add(b); } public ArrayList<B> getB() { return var; } public void setB(ArrayList<B> b) { this.var = b; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeTypedList(this.var); }

Error While Passing An Object From An Activity To Another (Using Parcelable)

半城伤御伤魂 提交于 2019-12-01 18:06:26
I Tried To Pass An Object Class From An Activity To Another Using Parcelable I've Create A Class And Name it Student package com.example.test08_passobjectoverintent; import android.os.Parcel; import android.os.Parcelable; public class Student implements Parcelable { private String st_AcadimicNumber ; private String st_Name ; private String st_Class ; public String getSt_AcadimicNumber() { return st_AcadimicNumber; } public void setSt_AcadimicNumber(String st_AcadimicNumber) { this.st_AcadimicNumber = st_AcadimicNumber; } public String getSt_Name() { return st_Name; } public void setSt_Name

Can't pass an ArrayList<Parcelable> to an activity

半城伤御伤魂 提交于 2019-12-01 17:49:52
问题 This is the code ArrayList<MyObject> list = new ArrayList<MyObject>(); list.add(new MyObject()); Intent intent = new Intent(this, ReceiverActivity.class); intent.putExtra("list", list); startActivity(intent); ReceiverActivity List<MyObject> list = (List<MyObject>)getIntent().getExtras().getParcelable("list"); Here list is null. Also this doesn't work: List<MyObject> list = (List<MyObject>)getIntent().getExtras().getSerializable("list"); MyObject is Parcelable, I implemented all required

Android Parcelable Implementation with ArrayList<Object>

帅比萌擦擦* 提交于 2019-12-01 16:39:50
so I am implementing a test app in which I will create a Tournament object as Parcelable and will pass them between intents. A tournament include: . A tournament name . Rule . Rule for matching players (random/manual) . An array list of Players This is what I have so far: Tournament.java public class TournamentData implements Parcelable { private String tourName; private int bestOf; private boolean isRandom; private ArrayList<Player> playerList; public TournamentData(String name, int tourBestOf, boolean random) { this.tourName = name; this.bestOf = tourBestOf; this.isRandom = random; } public

Error While Passing An Object From An Activity To Another (Using Parcelable)

血红的双手。 提交于 2019-12-01 16:24:11
问题 I Tried To Pass An Object Class From An Activity To Another Using Parcelable I've Create A Class And Name it Student package com.example.test08_passobjectoverintent; import android.os.Parcel; import android.os.Parcelable; public class Student implements Parcelable { private String st_AcadimicNumber ; private String st_Name ; private String st_Class ; public String getSt_AcadimicNumber() { return st_AcadimicNumber; } public void setSt_AcadimicNumber(String st_AcadimicNumber) { this.st

Does variable order matter while parcel read/write operation in Parcelable?

别来无恙 提交于 2019-12-01 05:26:17
I have the following implementation of a Parcelable class: public class DemoModel implements Parcelable { private String para1; private int para2; public DemoModel(){} protected DemoModel(Parcel in) { para1 = in.readString(); para2 = in.readInt(); } @Override public void writeToParcel(Parcel parcel, int i) { parcel.writeString(para1); parcel.writeInt(para2); } //other methods } Is it important to maintain order while write/read to the parcel? And why? Yes it does . Order of write variables is up to you and you can do it as you want, but you must read them in that same exact order. It will give

Does variable order matter while parcel read/write operation in Parcelable?

笑着哭i 提交于 2019-12-01 03:43:24
问题 I have the following implementation of a Parcelable class: public class DemoModel implements Parcelable { private String para1; private int para2; public DemoModel(){} protected DemoModel(Parcel in) { para1 = in.readString(); para2 = in.readInt(); } @Override public void writeToParcel(Parcel parcel, int i) { parcel.writeString(para1); parcel.writeInt(para2); } //other methods } Is it important to maintain order while write/read to the parcel? And why? 回答1: Yes it does . Order of write

java.lang.RuntimeException: Parcel android.os.Parcel: Unmarshalling unknown type code

旧时模样 提交于 2019-12-01 02:48:08
I seem to be getting a strange error in my app (see GitHub ), which occurs when I pass objects to different activities that implement Parcelable . I have checked other questions and answers here on Stack Overflow, but I was unable to find a solution. I've tried the answer here , for example - here it is for reference: -keepclassmembers class * implements android.os.Parcelable { static ** CREATOR; } I've also made sure that the method calls in writeToParcel are in order. Most other questions on Stack Overflow about this issue don't have answers. Moreover, the reason I am asking a new question

Size limitation on attached Parcelable?

喜夏-厌秋 提交于 2019-12-01 02:34:29
I want to know is there any size limitation on Parcelable that attached to an Intent ? I Read some docs about Intents , Bundles , Parcelable again and there was nothing about size limitation. But I read some answers , that say size of attached Parcelable is limited (for example, 1 MB). So are Parcelable s limited by size or it only depends to the device? Its explained on the docs here . The transaction buffer for each process is 1 mb. In my understanding the factors to be considered are: Individual size of transactions(maximum 1 mb) The number of transactions(the sum of size of all

Extending a class that implements Parcelable

非 Y 不嫁゛ 提交于 2019-11-30 22:41:17
问题 I have a class, we'll call it class A, that implements Parcelable. I have a second class, we'll call it class B, that extends class A. My question is: How do I write class B's member variables to the Parcel and then write it's parent class's (ie: class A's) member variables to the Parcel (and, subsequently, read them in)? Is there some nifty trick to not needing to rewrite class A's Parcel code? Or do I just need to rewrite the Parcel code in class A and add additional code for class B's