I am trying to access getter property of the pojo received in the response, but there is no such option.so is there any other way, I can do that?
The code for that call is as below:
results.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<GenericResponse<List<FoodTruck>>>() {
#Override
public void onCompleted() {
Toast.makeText(getActivity(), "completed", Toast.LENGTH_SHORT).show();
unsubscribe();
}
#Override
public void onError(Throwable e) {
Toast.makeText(getActivity(), "error", Toast.LENGTH_SHORT).show();
}
#Override
public void onNext(GenericResponse<List<FoodTruck>> response) {
Toast.makeText(getActivity(), response.toString(), Toast.LENGTH_SHORT).show();
}
});
GenericResponse.java
public class GenericResponse<T> {
#JsonProperty("status")
private String status;
#JsonProperty("message")
private String message;
#JsonProperty("data")
private T data;
}
FoodTruck.java
#JsonInclude(JsonInclude.Include.NON_NULL)
public class FoodTruck implements Parcelable {
#JsonProperty("_id")
private String foodTruckId;
#JsonProperty("foodtruck_name")
private String foodTruckName;
#JsonProperty("foodtruck_location")
private String foodTruckLocation;
#JsonProperty("foodtruck_tag")
private String foodTruckTag;
#JsonProperty("foodtruck_timing")
private String foodTruckTiming;
#JsonProperty("foodtruck_cusine")
private String foodTruckCusine;
#JsonProperty("foodtruck_img")
private String foodTruckImg;
#JsonProperty("foodtruck_logo")
private String foodTruckLogo;
#JsonProperty("foodtruck_total_votes")
private int foodTruckTotalVotes;
#JsonProperty("foodtruck_rating")
private double foodTruckRating;
#JsonProperty("item_list")
private List<FoodTruckItem> foodTruckItemList;
public String getFoodTruckId() {
return foodTruckId;
}
public String getFoodTruckName() {
return foodTruckName;
}
public String getFoodTruckLocation() {
return foodTruckLocation;
}
public String getFoodTruckTag() {
return foodTruckTag;
}
public String getFoodTruckTiming() {
return foodTruckTiming;
}
public String getFoodTruckCusine() {
return foodTruckCusine;
}
public String getFoodTruckImg() {
return foodTruckImg;
}
public String getFoodTruckLogo() {
return foodTruckLogo;
}
public int getFoodTruckTotalVotes() {
return foodTruckTotalVotes;
}
public double getFoodTruckRating() {
return foodTruckRating;
}
public List<FoodTruckItem> getFoodTruckItemList() {
return foodTruckItemList;
}
public void setFoodTruckId(String foodTruckId) {
this.foodTruckId = foodTruckId;
}
public void setFoodTruckName(String foodTruckName) {
this.foodTruckName = foodTruckName;
}
public void setFoodTruckLocation(String foodTruckLocation) {
this.foodTruckLocation = foodTruckLocation;
}
public void setFoodTruckTag(String foodTruckTag) {
this.foodTruckTag = foodTruckTag;
}
public void setFoodTruckTiming(String foodTruckTiming) {
this.foodTruckTiming = foodTruckTiming;
}
public void setFoodTruckCusine(String foodTruckCusine) {
this.foodTruckCusine = foodTruckCusine;
}
public void setFoodTruckImg(String foodTruckImg) {
this.foodTruckImg = foodTruckImg;
}
public void setFoodTruckLogo(String foodTruckLogo) {
this.foodTruckLogo = foodTruckLogo;
}
public void setFoodTruckTotalVotes(int foodTruckTotalVotes) {
this.foodTruckTotalVotes = foodTruckTotalVotes;
}
public void setFoodTruckRating(double foodTruckRating) {
this.foodTruckRating = foodTruckRating;
}
public void setFoodTruckItemList(List<FoodTruckItem> foodTruckItemList) {
this.foodTruckItemList = foodTruckItemList;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.foodTruckId);
dest.writeString(this.foodTruckName);
dest.writeString(this.foodTruckLocation);
dest.writeString(this.foodTruckTag);
dest.writeString(this.foodTruckTiming);
dest.writeString(this.foodTruckCusine);
dest.writeString(this.foodTruckImg);
dest.writeString(this.foodTruckLogo);
dest.writeInt(this.foodTruckTotalVotes);
dest.writeDouble(this.foodTruckRating);
dest.writeTypedList(this.foodTruckItemList);
}
public FoodTruck() {
}
protected FoodTruck(Parcel in) {
this.foodTruckId = in.readString();
this.foodTruckName = in.readString();
this.foodTruckLocation = in.readString();
this.foodTruckTag = in.readString();
this.foodTruckTiming = in.readString();
this.foodTruckCusine = in.readString();
this.foodTruckImg = in.readString();
this.foodTruckLogo = in.readString();
this.foodTruckTotalVotes = in.readInt();
this.foodTruckRating = in.readDouble();
this.foodTruckItemList = in.createTypedArrayList(FoodTruckItem.CREATOR);
}
public static final Parcelable.Creator<FoodTruck> CREATOR = new Parcelable.Creator<FoodTruck>() {
#Override
public FoodTruck createFromParcel(Parcel source) {
return new FoodTruck(source);
}
#Override
public FoodTruck[] newArray(int size) {
return new FoodTruck[size];
}
};
}
FoodTruckItem.java
#JsonInclude(JsonInclude.Include.NON_NULL)
public class FoodTruckItem implements Parcelable {
#JsonProperty("_id")
private String itemId;
#JsonProperty("no_of_times_ordered")
private int noOfTimesOrdered;
#JsonProperty("item_name")
private String itemName;
#JsonProperty("item_tag")
private String itemTag;
#JsonProperty("item_category")
private String itemCategory;
#JsonProperty("item_stock")
private int itemStock;
#JsonProperty("item_price")
private double itemPrice;
#JsonProperty("item_img")
private String itemImg;
#JsonProperty("no_of_likes")
private int noOfLikes;
#JsonProperty("item_quantity_ordered")
private int itemQuantityOrdered;
#JsonProperty("item_illustrations")
private List<String> itemIllustration;
public String getItemId() {
return itemId;
}
public int getNoOfTimesOrdered() {
return noOfTimesOrdered;
}
public String getItemName() {
return itemName;
}
public String getItemTag() {
return itemTag;
}
public String getItemCategory() {
return itemCategory;
}
public int getItemStock() {
return itemStock;
}
public double getItemPrice() {
return itemPrice;
}
public String getItemImg() {
return itemImg;
}
public int getNoOfLikes() {
return noOfLikes;
}
public int getItemQuantityOrdered() {
return itemQuantityOrdered;
}
public List<String> getItemIllustration() {
return itemIllustration;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public void setNoOfTimesOrdered(int noOfTimesOrdered) {
this.noOfTimesOrdered = noOfTimesOrdered;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public void setItemTag(String itemTag) {
this.itemTag = itemTag;
}
public void setItemCategory(String itemCategory) {
this.itemCategory = itemCategory;
}
public void setItemStock(int itemStock) {
this.itemStock = itemStock;
}
public void setItemPrice(double itemPrice) {
this.itemPrice = itemPrice;
}
public void setItemImg(String itemImg) {
this.itemImg = itemImg;
}
public void setNoOfLikes(int noOfLikes) {
this.noOfLikes = noOfLikes;
}
public void setItemQuantityOrdered(int itemQuantityOrdered) {
this.itemQuantityOrdered = itemQuantityOrdered;
}
public void setItemIllustration(List<String> itemIllustration) {
this.itemIllustration = itemIllustration;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.itemId);
dest.writeInt(this.noOfTimesOrdered);
dest.writeString(this.itemName);
dest.writeString(this.itemTag);
dest.writeString(this.itemCategory);
dest.writeInt(this.itemStock);
dest.writeDouble(this.itemPrice);
dest.writeString(this.itemImg);
dest.writeInt(this.noOfLikes);
dest.writeInt(this.itemQuantityOrdered);
dest.writeStringList(this.itemIllustration);
}
public FoodTruckItem() {
}
protected FoodTruckItem(Parcel in) {
this.itemId = in.readString();
this.noOfTimesOrdered = in.readInt();
this.itemName = in.readString();
this.itemTag = in.readString();
this.itemCategory = in.readString();
this.itemStock = in.readInt();
this.itemPrice = in.readDouble();
this.itemImg = in.readString();
this.noOfLikes = in.readInt();
this.itemQuantityOrdered = in.readInt();
this.itemIllustration = in.createStringArrayList();
}
public static final Parcelable.Creator<FoodTruckItem> CREATOR = new Parcelable.Creator<FoodTruckItem>() {
#Override
public FoodTruckItem createFromParcel(Parcel source) {
return new FoodTruckItem(source);
}
#Override
public FoodTruckItem[] newArray(int size) {
return new FoodTruckItem[size];
}
};
}
Now Basically I want to acess someting like response.getData().... But there is no such option.
Possibly data not accessible, because it is private. Try to crete getter method.
public class GenericResponse<T> {
#JsonProperty("status")
private String status;
#JsonProperty("message")
private String message;
#JsonProperty("data")
private T data;
public T getData() {
return data;
}
}
Related
I am quite familiar with Json parsing with Gson. I have done Json parsing using Gson but recently i have multiple json objects with response, i am getting little bit stuck with parsing, here is my code,can anyone help me to solve my problem,that where i am doing wrong.
Thanks in advance
Here is my json response :-
Json response
Here is my POGO class of parsing :-
Style Profile.java
public class StyleProfile implements Parcelable {
#SerializedName("user_name")
#Expose
private String user_name;
#SerializedName("user_picture")
#Expose
private String user_picture;
#SerializedName("user_attr")
#Expose
private UserAttrEntity user_attr;
#SerializedName("user_attributes")
#Expose
private UserAttributes userAttributes;
#SerializedName("style_attr")
#Expose
private StyleAttr style_attr;
private StyleAttrEntity style_attrEntity;
private UserAttributesEntity user_attributes;
private String user_style;
#SerializedName("user_background_image")
#Expose
private String userBackgroundImage;
#SerializedName("user_style_message")
#Expose
private String userStyleMessage;
private String user_style_message;
private List<String> style_message;
public StyleProfile() {
}
protected StyleProfile(Parcel in)
{
user_name = in.readString();
user_picture = in.readString();
user_style = in.readString();
// style_message = in.readString();
}
public static final Creator<StyleProfile> CREATOR = new Creator<StyleProfile>() {
#Override
public StyleProfile createFromParcel(Parcel in) {
return new StyleProfile(in);
}
#Override
public StyleProfile[] newArray(int size) {
return new StyleProfile[size];
}
};
public StyleAttr getStyle_attr() {
return style_attr;
}
public void setStyle_attr(StyleAttr style_attr) {
this.style_attr = style_attr;
}
public String getName() {
return user_name;
}
public void setName(String name) {
this.user_name = name;
}
public String getImage() {
return user_picture;
}
public void setImage(String image) {
this.user_picture = image;
}
public UserAttrEntity getUser_attr() {
return user_attr;
}
public void setUser_attributes(UserAttributesEntity user_attributes) {
this.user_attributes = user_attributes;
}
public void setUser_style(String user_style) {
this.user_style = user_style;
}
public String getUser_style() {
return user_style;
}
public List<String> getStyle_message() {
return style_message;
}
public void setStyle_message(List<String> style_message) {
this.style_message = style_message;
}
public String getStyleMessageAsString() {
return TextUtils.join(". ", style_message);
}
public void setUser_style_message(String user_style_message) {
this.user_style_message = user_style_message;
}
public String getUser_style_message() {
return user_style_message;
}
public UserAttributesEntity getUser_attributes() {
return user_attributes;
}
public void setUser_attr(UserAttrEntity user_attr) {
this.user_attr = user_attr;
}
public UserAttributes getUserAttr() {
return userAttributes;
}
public void setUserAttr(UserAttributes userAttr) {
this.userAttributes = userAttr;
}
public UserAttributes getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(UserAttributes userAttributes) {
this.userAttributes = userAttributes;
}
public String getUserStyle() {
return user_style;
}
public void setUserStyle(String userStyle) {
this.user_style = userStyle;
}
public String getUserBackgroundImage() {
return userBackgroundImage;
}
public void setUserBackgroundImage(String userBackgroundImage) {
this.userBackgroundImage = userBackgroundImage;
}
public String getUserStyleMessage() {
return userStyleMessage;
}
public void setUserStyleMessage(String userStyleMessage) {
this.userStyleMessage = userStyleMessage;
}
#Override
public int describeContents() {
return 0;
}
public StyleAttrEntity getStyle_attrEntity() {
return style_attrEntity;
}
public static Creator<StyleProfile> getCREATOR() {
return CREATOR;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(user_name);
dest.writeString(user_picture);
dest.writeParcelable(user_attr, flags);
dest.writeParcelable(style_attr, flags);
dest.writeString(user_style);
}
public void setStyle_attrEntity(StyleAttrEntity style_attrEntity) {
this.style_attrEntity = style_attrEntity;
}
public static class StyleAttr implements Parcelable {
#SerializedName("Edgy")
#Expose
private Integer edgy;
#SerializedName("Feminine")
#Expose
private Integer feminine;
#SerializedName("Fashion Forward")
#Expose
private Integer fashionForward;
#SerializedName("Classic")
#Expose
private Integer classic;
#SerializedName("Casual")
#Expose
private Integer casual;
#SerializedName("Bohemian")
#Expose
private Integer bohemian;
protected StyleAttr(Parcel in) {
edgy = in.readInt();
casual = in.readInt();
classic = in.readInt();
edgy = in.readInt();
fashionForward = in.readInt();
feminine = in.readInt();
}
public static final Creator<StyleAttr> CREATOR = new Creator<StyleAttr>() {
#Override
public StyleAttr createFromParcel(Parcel in) {
return new StyleAttr(in);
}
#Override
public StyleAttr[] newArray(int size) {
return new StyleAttr[size];
}
};
public void setBohemian(int Bohemian) {
this.bohemian = Bohemian;
}
public void setCasual(int Casual) {
this.casual = Casual;
}
public void setClassic(int Classic) {
this.classic = Classic;
}
public void setEdgy(int Edgy) {
this.edgy = Edgy;
}
public void setFashionForward(int FashionForward) {
this.fashionForward = FashionForward;
}
public void setFeminine(int Feminine) {
this.feminine = Feminine;
}
public int getBohemian() {
return bohemian;
}
public int getCasual() {
return casual;
}
public int getClassic() {
return classic;
}
public int getEdgy() {
return edgy;
}
public int getFashionForward() {
return fashionForward;
}
public int getFeminine() {
return feminine;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(bohemian);
dest.writeInt(casual);
dest.writeInt(classic);
dest.writeInt(edgy);
dest.writeInt(fashionForward);
dest.writeInt(feminine);
}
}
}
UserAttrEntity.java
public class UserAttrEntity implements Parcelable {
#SerializedName("Size")
private String Size = "";
#SerializedName("Shape")
private String Shape = "";
#SerializedName("Bottoms Size")
private String Bottoms_Size = "";
#SerializedName("Height")
private String Height = "";
#SerializedName("Shoes Size")
private String Shoes_Size = "";
#SerializedName("Complexion")
private String Face_Color = "";
#SerializedName("Face Shape")
private String Face_Shape = "";
public UserAttrEntity() {
}
protected UserAttrEntity(Parcel in) {
Shape = in.readString();
Size = in.readString();
Bottoms_Size = in.readString();
Height = in.readString();
Shoes_Size = in.readString();
Face_Color = in.readString();
Face_Shape = in.readString();
}
public static final Creator<UserAttrEntity> CREATOR = new Creator<UserAttrEntity>() {
#Override
public UserAttrEntity createFromParcel(Parcel in) {
return new UserAttrEntity(in);
}
#Override
public UserAttrEntity[] newArray(int size) {
return new UserAttrEntity[size];
}
};
public void setShape(String Shape) {
this.Shape = Shape;
}
public void setSize(String Size) {
this.Size = Size.replace("\n", " ");
}
public void setBottoms_Size(String Bottoms_Size) {
this.Bottoms_Size = Bottoms_Size + " Inch";
}
public void setHeight(String Height) {
this.Height = Height;
}
public void setShoes_Size(String Shoes_Size) {
this.Shoes_Size = Shoes_Size;
}
public void setFace_Color(String Face_Color) {
this.Face_Color = Face_Color;
}
public void setFace_Shape(String Face_Shape) {
this.Face_Shape = Face_Shape;
}
public String getShape() {
return Shape;
}
public String getSize() {
return Size;
}
public String getBottoms_Size() {
return Bottoms_Size;
}
public String getHeight() {
return Height;
}
public String getShoes_Size() {
return Shoes_Size;
}
public String getFace_Color() {
return Face_Color;
}
public String getFace_Shape() {
return Face_Shape;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(Shape);
dest.writeString(Size);
dest.writeString(Bottoms_Size);
dest.writeString(Height);
dest.writeString(Shoes_Size);
dest.writeString(Face_Color);
dest.writeString(Face_Shape);
}
}
User AttributesEntity.java
public class UserAttributes {
#SerializedName("Size")
#Expose
private Size size;
#SerializedName("Shape")
#Expose
private Shape shape;
#SerializedName("Bottoms Size")
#Expose
private BottomsSize bottomsSize;
#SerializedName("Height")
#Expose
private Height height;
#SerializedName("Shoes Size")
#Expose
private ShoesSize shoesSize;
#SerializedName("Complexion")
#Expose
private Complexion complexion;
#SerializedName("Face Shape")
#Expose
private FaceShape faceShape;
public Size getSize() {
return size;
}
public void setSize(Size size) {
this.size = size;
}
public Shape getShape() {
return shape;
}
public void setShape(Shape shape) {
this.shape = shape;
}
public BottomsSize getBottomsSize() {
return bottomsSize;
}
public void setBottomsSize(BottomsSize bottomsSize) {
this.bottomsSize = bottomsSize;
}
public Height getHeight() {
return height;
}
public void setHeight(Height height) {
this.height = height;
}
public ShoesSize getShoesSize() {
return shoesSize;
}
public void setShoesSize(ShoesSize shoesSize) {
this.shoesSize = shoesSize;
}
public Complexion getComplexion() {
return complexion;
}
public void setComplexion(Complexion complexion) {
this.complexion = complexion;
}
public FaceShape getFaceShape() {
return faceShape;
}
public void setFaceShape(FaceShape faceShape) {
this.faceShape = faceShape;
}
}
Style Profile.java
Here i am using it like this
Profile profile = gson.fromJson(obj.toString(), Profile.class);
Log.e("", "profile.getStatus() " + profile.getStatus());
mReceiver.onResponse(profile, tag);
Try this way
//Main data
public class MainData{
#SerializedName("status")
#Expose
private String status;
#SerializedName("data")
#Expose
private Data data;
}
//Data
public class Data {
#SerializedName("user_name")
#Expose
private String userName;
#SerializedName("user_picture")
#Expose
private String userPicture;
#SerializedName("user_attr")
#Expose
private UserAttr userAttr;
#SerializedName("user_attributes")
#Expose
private UserAttributes userAttributes;
#SerializedName("style_attr")
#Expose
private StyleAttr styleAttr;
#SerializedName("user_style")
#Expose
private String userStyle;
#SerializedName("user_background_image")
#Expose
private String userBackgroundImage;
#SerializedName("user_style_message")
#Expose
private String userStyleMessage;
}
//user_attr
public class UserAttr {
#SerializedName("user_attr")
private Map<String, String> userAttributes;
public Map<String, String> getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(Map<String, String> userattributes) {
this.userAttributes= userattributes;
}
}
//user_attributes
public class UserAttributes {
#SerializedName("user_attributes")
private Map<String, CommonUserAttributes> userAttributes;
public Map<String, CommonUserAttributes> getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(Map<String, CommonUserAttributes> userattributes) {
this.userAttributes = userattributes;
}
}
//StyleAttr
public class StyleAttr {
#SerializedName("style_attr")
private Map<String, Integer> styleAttributes;
public Map<String, Integer> getStyleAttributes() {
return styleAttributes;
}
public void setStyleAttributes(Map<String, Integer> styleAttributes) {
this.styleAttributes = styleAttributes;
}
}
//CommonUserAttributes
public class CommonUserAttributes {
#SerializedName("user_attr")
private String value;
#SerializedName("que_id")
private String bottmque_id;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getBottmque_id() {
return bottmque_id;
}
public void setBottmque_id(String bottmque_id) {
this.bottmque_id = bottmque_id;
}
}
put your get,set method yourself.
Folks, I'm getting mad with parcelables.
Here goes, I have these lines:
Intent i = new Intent(context, PaymentDetailsActivity.class);
i.putExtra(ConstantsUtils.PARAM_INTENT_ORDER_DETAILS, responseOrderInfoApiModel);
i.putExtra(ConstantsUtils.PARAM_INTENT_PAYMENT_INFO, paymentInfoViewModel);
startActivity(i);
and here I receive my parcelables:
Intent receivedIntent = getIntent();
responseOrderInfoApiModel = receivedIntent.getParcelableExtra(ConstantsUtils.PARAM_INTENT_ORDER_DETAILS);
paymentInfoViewModel = receivedIntent.getParcelableExtra(ConstantsUtils.PARAM_INTENT_PAYMENT_INFO);
The point is, responseOrderInfoApiModel is receiving a null, but it shouldn't, however if I comment the line:
i.putExtra(ConstantsUtils.PARAM_INTENT_PAYMENT_INFO, paymentInfoViewModel);
My responseOrderInfoApiModel receive the correct value.
Here goes my parcelables:
ResponseOrderInfoApiModel -
public class ResponseOrderInfoApiModel implements Parcelable{
private String cardNumber;
private double total;
private ArrayList<ResponseOrderItemApiModel> listItem;
public ResponseOrderInfoApiModel() {
}
public ResponseOrderInfoApiModel(Parcel source) {
if(listItem == null){
listItem = new ArrayList<>();
}
setCardNumber(source.readString());
setTotal(source.readDouble());
source.readTypedList(listItem, ResponseOrderItemApiModel.CREATOR);
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(cardNumber);
dest.writeDouble(total);
dest.writeTypedList(listItem);
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
#Override
public ResponseOrderInfoApiModel createFromParcel(Parcel source) {
return new ResponseOrderInfoApiModel(source);
}
#Override
public ResponseOrderInfoApiModel[] newArray(int size) {
return new ResponseOrderInfoApiModel[size];
}
};
#Override
public int describeContents() {
return 0;
}
public ArrayList<ResponseOrderItemApiModel> getListItem() {
return listItem;
}
public void setListItem(ArrayList<ResponseOrderItemApiModel> listItem) {
this.listItem = listItem;
}
public String getCardNumber() {
return cardNumber;
}
public void setCardNumber(String cardNumber) {
this.cardNumber = cardNumber;
}
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
}
ResponseOrderItemApiModel (is a arrayList in ResponseOrderInfoApiModel) -
public class ResponseOrderItemApiModel implements Parcelable {
private String description;
private int quantity;
private double total;
private double unitPrice;
public ResponseOrderItemApiModel() {
}
public ResponseOrderItemApiModel(Parcel source) {
setDescription(source.readString());
setQuantity(source.readInt());
setTotal(source.readDouble());
setUnitPrice(source.readDouble());
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(description);
dest.writeInt(quantity);
dest.writeDouble(total);
dest.writeDouble(unitPrice);
}
public static Parcelable.Creator<ResponseOrderItemApiModel> CREATOR = new Parcelable.Creator<ResponseOrderItemApiModel>(){
#Override
public ResponseOrderItemApiModel createFromParcel(Parcel source) {
return new ResponseOrderItemApiModel(source);
}
#Override
public ResponseOrderItemApiModel[] newArray(int size) {
return new ResponseOrderItemApiModel[size];
}
};
#Override
public int describeContents() {
return 0;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
public double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(double unitPrice) {
this.unitPrice = unitPrice;
}
}
PaymentInfoViewModel -
public class PaymentInfoViewModel implements Parcelable {
private long idEstablishment;
private String nameEstablishment;
private int cardNumber;
private double cardSubTotalValue;
private double cardTotalValue;
private byte tipPercentage;
private long idCardPayment;
public PaymentInfoViewModel() {
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
#Override
public PaymentInfoViewModel createFromParcel(Parcel source) {
return new PaymentInfoViewModel(source);
}
#Override
public PaymentInfoViewModel[] newArray(int size) {
return new PaymentInfoViewModel[size];
}
};
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(idEstablishment);
dest.writeString(nameEstablishment);
dest.writeInt(cardNumber);
dest.writeDouble(cardSubTotalValue);
dest.writeDouble(cardTotalValue);
dest.writeByte(tipPercentage);
dest.writeLong(idCardPayment);
}
public PaymentInfoViewModel(Parcel source) {
setIdEstablishment(source.readLong());
setNameEstablishment(source.readString());
setCardNumber(source.readInt());
setCardSubTotalValue(source.readDouble());
setCardTotalValue(source.readDouble());
setTipPercentage(source.readByte());
setIdCardPayment(idCardPayment);
}
public long getIdEstablishment() {
return idEstablishment;
}
public void setIdEstablishment(long idEstablishment) {
this.idEstablishment = idEstablishment;
}
public String getNameEstablishment() {
return nameEstablishment;
}
public void setNameEstablishment(String nameEstablishment) {
this.nameEstablishment = nameEstablishment;
}
public int getCardNumber() {
return cardNumber;
}
public void setCardNumber(int cardNumber) {
this.cardNumber = cardNumber;
}
public double getCardTotalValue() {
return cardTotalValue;
}
public void setCardTotalValue(double cardTotalValue) {
this.cardTotalValue = cardTotalValue;
}
public byte getTipPercentage() {
return tipPercentage;
}
public void setTipPercentage(byte tipPercentage) {
this.tipPercentage = tipPercentage;
}
public double getCardSubTotalValue() {
return cardSubTotalValue;
}
public void setCardSubTotalValue(double cardSubTotalValue) {
this.cardSubTotalValue = cardSubTotalValue;
}
public long getIdCardPayment() {
return idCardPayment;
}
public void setIdCardPayment(long idCardPayment) {
this.idCardPayment = idCardPayment;
}
}
Try using bundle and put your data in bundle and then put bundle in to intent. Once i had such a funny problem and this method solved my problem.
I have a problem with unmarshaling an parcelable object.
The exception is not reproducible every time but sometimes yes.
Here is the definition of the parcelable object :
public class Article extends DBOperationHolder implements Parcelable {
private static final String TAG = "Article_Object";
#SerializedName("article_id")
private int mId;
#SerializedName("city_id")
private int mCityId;
#SerializedName("categories")
private List<Integer> mCategories;
#SerializedName("neighborhood_tags")
private List<Integer> mNeighborhoodTags;
#SerializedName("cuisine_tags")
private List<Integer> mCuisineTags;
#SerializedName("collection_articles")
private List<Integer> mCollectionArticles;
#SerializedName("rating")
private int mRating;
#SerializedName("title")
private String mTitle;
#SerializedName("subtitle")
private String mSubTitle;
#SerializedName("summary")
private String mSummary;
#SerializedName("text")
private String mText;
#SerializedName("main_image_url")
private String mMainImgUrl;
#SerializedName("images")
private List<String> mImages;
#SerializedName("date_from")
private String mDateFrom;
#SerializedName("date_to")
private String mDateTo;
#SerializedName("venue_name")
private String mVenueName;
#SerializedName("address")
private String mAddress;
#SerializedName("address_latitude")
private double mAddressLatitude;
#SerializedName("address_longitude")
private double mAddressLongitude;
#SerializedName("contact_person")
private String mContactPerson;
#SerializedName("contact_email")
private String mContactEmail;
#SerializedName("contact_telephone")
private String mContactTelephone;
#SerializedName("contact_website")
private String mContactWebsite;
#SerializedName("style")
private String mStyle;
#SerializedName("ideal_for")
private String mIdealFor;
#SerializedName("favorite_tables")
private String mFavoriteTables;
#SerializedName("favorite_room")
private String mFavoriteRoom;
#SerializedName("signature_dishes")
private String mSignatureDishes;
#SerializedName("signature_drinks")
private String mSignatureDrinks;
#SerializedName("highlights")
private String mHighLights;
#SerializedName("type")
private String mType;
#SerializedName("membership_price")
private String mMemberShipPrice;
#SerializedName("membership_benefits")
private String mMemberShipBenefits;
#SerializedName("publish_date")
private String mPublishDate;
#SerializedName("article_url")
private String mArticleUrl;
private String mTag;
private boolean mIsCollection;
private int mIsAddedInFavorites;
private int mCategoryColor;
private String mCuisine;
private int mCategoryId;
public Article() {
}
public Article(int id) {
mId = id;
}
private Article(Parcel in) {
mId = in.readInt();
mCityId = in.readInt();
mRating = in.readInt();
mTitle = in.readString();
mSubTitle = in.readString();
mSummary = in.readString();
mText = in.readString();
mMainImgUrl = in.readString();
mDateFrom = in.readString();
mDateTo = in.readString();
mVenueName = in.readString();
mAddress = in.readString();
mAddressLatitude = in.readFloat();
mAddressLongitude = in.readFloat();
mContactPerson = in.readString();
mContactEmail = in.readString();
mContactTelephone = in.readString();
mContactWebsite = in.readString();
mStyle = in.readString();
mIdealFor = in.readString();
mFavoriteTables = in.readString();
mFavoriteRoom = in.readString();
mSignatureDishes = in.readString();
mSignatureDrinks = in.readString();
mHighLights = in.readString();
mType = in.readString();
mMemberShipPrice = in.readString();
mMemberShipBenefits = in.readString();
mPublishDate = in.readString();
mIsAddedInFavorites = in.readInt();
mTag = in.readString();
mCategoryColor = in.readInt();
mCuisine = in.readString();
mCategoryId = in.readInt();
mArticleUrl = in.readString();
}
#Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeInt(mId);
parcel.writeInt(mCityId);
parcel.writeInt(mRating);
parcel.writeString(mTitle);
parcel.writeString(mSubTitle);
parcel.writeString(mSummary);
parcel.writeString(mText);
parcel.writeString(mMainImgUrl);
parcel.writeString(mDateFrom);
parcel.writeString(mDateTo);
parcel.writeString(mVenueName);
parcel.writeString(mAddress);
parcel.writeDouble(mAddressLatitude);
parcel.writeDouble(mAddressLongitude);
parcel.writeString(mContactPerson);
parcel.writeString(mContactEmail);
parcel.writeString(mContactTelephone);
parcel.writeString(mContactWebsite);
parcel.writeString(mStyle);
parcel.writeString(mIdealFor);
parcel.writeString(mFavoriteTables);
parcel.writeString(mFavoriteRoom);
parcel.writeString(mSignatureDishes);
parcel.writeString(mSignatureDrinks);
parcel.writeString(mHighLights);
parcel.writeString(mType);
parcel.writeString(mMemberShipPrice);
parcel.writeString(mMemberShipBenefits);
parcel.writeString(mPublishDate);
parcel.writeInt(mIsAddedInFavorites);
parcel.writeString(mTag);
parcel.writeInt(mCategoryColor);
parcel.writeString(mCuisine);
parcel.writeInt(mCategoryId);
parcel.writeString(mArticleUrl);
}
#Override
public int describeContents() {
return 0;
}
public static Creator<Article> CREATOR = new Creator<Article>() {
#Override
public Article createFromParcel(Parcel source) {
return new Article(source);
}
#Override
public Article[] newArray(int size) {
return new Article[size];
}
};
public String getMainImgUrl() {
if (TextUtils.isEmpty(mMainImgUrl)) {
if (!CollectionUtil.isEmpty(mImages)) {
mMainImgUrl = mImages.get(0);
}
}
return mMainImgUrl;
}
public int getId() {
return mId;
}
public void setId(int id) {
mId = id;
}
public int getCityId() {
return mCityId;
}
public void setCityId(int cityId) {
mCityId = cityId;
}
public List<Integer> getCategories() {
return mCategories;
}
public void setCategories(List<Integer> categories) {
mCategories = categories;
}
public List<Integer> getNeighborhoodTags() {
return mNeighborhoodTags;
}
public void setNeighborhoodTags(List<Integer> neighborhoodTags) {
mNeighborhoodTags = neighborhoodTags;
}
public List<Integer> getCuisineTags() {
return mCuisineTags;
}
public void setCuisineTags(List<Integer> cuisineTags) {
mCuisineTags = cuisineTags;
}
public List<Integer> getCollectionArticles() {
return mCollectionArticles;
}
public void setCollectionArticles(List<Integer> collectionArticles) {
mCollectionArticles = collectionArticles;
}
public int getRating() {
return mRating;
}
public void setRating(int rating) {
mRating = rating;
}
public String getTitle() {
return mTitle;
}
public void setTitle(String title) {
mTitle = title;
}
public String getSubTitle() {
return mSubTitle;
}
public void setSubTitle(String subTitle) {
mSubTitle = subTitle;
}
public String getSummary() {
return mSummary;
}
public void setSummary(String summary) {
mSummary = summary;
}
public String getText() {
return mText;
}
public void setText(String text) {
mText = text;
}
public void setMainImgUrl(String mainImgUrl) {
mMainImgUrl = mainImgUrl;
}
public List<String> getImages() {
return mImages;
}
public void setImages(List<String> images) {
mImages = images;
}
public String getDateFrom() {
return mDateFrom;
}
public void setDateFrom(String dateFrom) {
mDateFrom = dateFrom;
}
public String getDateTo() {
return mDateTo;
}
public void setDateTo(String dateTo) {
mDateTo = dateTo;
}
public String getVenueName() {
return mVenueName;
}
public void setVenueName(String venueName) {
mVenueName = venueName;
}
public String getAddress() {
return mAddress;
}
public void setAddress(String address) {
mAddress = address;
}
public double getLatitude() {
return mAddressLatitude;
}
public void setLatitude(double addressLatitude) {
mAddressLatitude = addressLatitude;
}
public double getLongitude() {
return mAddressLongitude;
}
public void setLongitude(double addressLongitude) {
mAddressLongitude = addressLongitude;
}
public String getContactPerson() {
return mContactPerson;
}
public void setContactPerson(String contactPerson) {
mContactPerson = contactPerson;
}
public String getContactEmail() {
return mContactEmail;
}
public void setContactEmail(String contactEmail) {
mContactEmail = contactEmail;
}
public String getContactTelephone() {
return mContactTelephone;
}
public void setContactTelephone(String contactTelephone) {
mContactTelephone = contactTelephone;
}
public String getContactWebsite() {
return mContactWebsite;
}
public void setContactWebsite(String contactWebsite) {
mContactWebsite = contactWebsite;
}
public String getStyle() {
return mStyle;
}
public void setStyle(String style) {
mStyle = style;
}
public String getIdealFor() {
return mIdealFor;
}
public void setIdealFor(String idealFor) {
mIdealFor = idealFor;
}
public String getFavoriteTables() {
return mFavoriteTables;
}
public void setFavoriteTables(String favoriteTables) {
mFavoriteTables = favoriteTables;
}
public String getFavoriteRoom() {
return mFavoriteRoom;
}
public void setFavoriteRoom(String favoriteRoom) {
mFavoriteRoom = favoriteRoom;
}
public String getSignatureDishes() {
return mSignatureDishes;
}
public void setSignatureDishes(String signatureDishes) {
mSignatureDishes = signatureDishes;
}
public String getSignatureDrinks() {
return mSignatureDrinks;
}
public void setSignatureDrinks(String signatureDrinks) {
mSignatureDrinks = signatureDrinks;
}
public String getHighLights() {
return mHighLights;
}
public void setHighLights(String highLights) {
mHighLights = highLights;
}
public String getType() {
return mType;
}
public void setType(String type) {
mType = type;
}
public String getMemberShipPrice() {
return mMemberShipPrice;
}
public void setMemberShipPrice(String memberShipPrice) {
mMemberShipPrice = memberShipPrice;
}
public String getMemberShipBenefits() {
return mMemberShipBenefits;
}
public void setMemberShipBenefits(String memberShipBenefits) {
mMemberShipBenefits = memberShipBenefits;
}
public String getPublishDate() {
return mPublishDate;
}
public void setPublishDate(String publishDate) {
mPublishDate = publishDate;
}
public String getArticleUrl() {
return mArticleUrl;
}
public void setArticleUrl(String articleUrl) {
mArticleUrl = articleUrl;
}
public String getTag() {
return mTag;
}
public void setTag(String tag) {
UrbLog.d(TAG,"setTag("+tag+")");
mTag = tag;
}
public boolean isCollection() {
return mCategoryId == Category.COLLECTION_ID;
}
public int getIsAddedInFavorites() {
return mIsAddedInFavorites;
}
public void setIsAddedInFavorites(int isAddedInFavorites) {
mIsAddedInFavorites = isAddedInFavorites;
}
public int getCategoryColor() {
return mCategoryColor;
}
public void setCategoryColor(int categoryColor) {
mCategoryColor = categoryColor;
}
public String getCuisine() {
return mCuisine;
}
public void setCuisine(String cuisine) {
mCuisine = cuisine;
}
public int getCategoryId() {
return mCategoryId;
}
public void setCategoryId(int categoryId) {
mCategoryId = categoryId;
}
}
I`m trying to unmarshal the parcelable in the fragment's onCreate method here
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null) {
mArticle = args.getParcelable(Consts.ARTICLE_KEY);
}
}
Then not every time I received a crash with the following state:
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel#3348215c: Unmarshalling unknown type code 7602280 at offset 4068
at android.os.Parcel.readValue(Parcel.java:2222)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.Bundle.getParcelable(Bundle.java:804)
at com.appscollider.urbanologie.fragments.ArticleFragment.onCreate(ArticleFragment.java:233)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1766)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:917)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1120)
at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1924)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:268)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:58)
What is the reason for that exception and how I could fix it.
Thank you.
Your mAddressLatitude and mAddressLongitude are of type double and you are unmarshalling them as type float:
mAddressLatitude = in.readFloat();
mAddressLongitude = in.readFloat();
If you are writing it as double it should be:
mAddressLatitude = in.readDouble();
mAddressLongitude = in.readDouble();
I am sending an object from an antivity to other. the class is:
public class Reparacion implements Parcelable {
private int tipo;
private int estado;
private int id;
private String razonSocial;
private String direccion;
private String contacto;
private String telefono;
private String detalle;
public Reparacion() {
}
public Reparacion(int tipo, int estado, int id, String razSoc, String dir,
String contacto, String tfno, String detalle) {
this.tipo = tipo;
this.estado = estado;
this.id = id;
this.razonSocial = razSoc;
this.direccion = dir;
this.contacto = contacto;
this.telefono = tfno;
this.detalle = detalle;
}
public String getContacto() {
return contacto;
}
public void setContacto(String contacto) {
this.contacto = contacto;
}
public String getTelefono() {
return telefono;
}
public void setTelefono(String telefono) {
this.telefono = telefono;
}
public String getDetalle() {
return detalle;
}
public void setDetalle(String detalle) {
this.detalle = detalle;
}
public int getTipo() {
return tipo;
}
public void setTipo(int tipo) {
this.tipo = tipo;
}
public String getRazonSocial() {
return razonSocial;
}
public void setRazonSocial(String razonSocial) {
this.razonSocial = razonSocial;
}
public String getDireccion() {
return direccion;
}
public void setDireccion(String direccion) {
this.direccion = direccion;
}
public int getEstado() {
return estado;
}
public void setEstado(int estado) {
this.estado = estado;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
#Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.tipo);
dest.writeInt(this.estado);
dest.writeLong(this.id);
dest.writeString(this.razonSocial);
dest.writeString(this.direccion);
dest.writeString(this.contacto);
dest.writeString(this.telefono);
dest.writeString(this.detalle);
}
public Reparacion(Parcel in) {
readFromParcel(in);
}
private void readFromParcel(Parcel in) {
this.tipo = in.readInt();
this.estado = in.readInt();
this.id = in.readInt();
this.razonSocial = in.readString();
this.direccion = in.readString();
this.contacto = in.readString();
this.telefono = in.readString();
this.detalle = in.readString();
}
public static final Parcelable.Creator<Reparacion> CREATOR = new Parcelable.Creator<Reparacion>() {
public Reparacion createFromParcel(Parcel in) {
return new Reparacion(in);
}
public Reparacion[] newArray(int size) {
return new Reparacion[size];
}
};
public void almacenar(Context contexto){
ReparacionBBDD rbd=new ReparacionBBDD(contexto);
rbd.insert(this);
}
public void eliminar(Context contexto){
ReparacionBBDD rbd=new ReparacionBBDD(contexto);
rbd.delete(this);
}
public void actualizar(Context contexto){
ReparacionBBDD rbd=new ReparacionBBDD(contexto);
rbd.update(this);
}
}
The problem is that I can recovery the int data, but the string data is null when I received the object. how is it possible???
I have read a lot of codes, and I have do it a lot of times, but I don't know the mistake!!
very thanks!!!
You must retrieve data as the way (data-type & order) you added. So this line can cause the issue:
dest.writeLong(this.id);
Replace that with:
dest.writeInt(this.id);
I am using Serializable interface to send user defined data from one activity to another.
Here is my code :
TasksheetData[] alltasks = new TasksheetData();
Intent in=new Intent(TaskSheetList.this, TaskDetails.class);
in.putExtra("TaskSheetData", alltasks);
and in other activity I am accessing this object like :
TasksheetData tData = (TasksheetData) getIntent().getSerializableExtra("TaskSheetData");
and here is my TasksheetData class
#SuppressWarnings("serial")
public class TasksheetData implements Serializable {
private int TaskID;
private int AttendantID;
private String AttendentName;
private String ReservationID;
private String ResStatusCode;
private int InspectionStartedById;
private String HKStatusCode;
private int FOStatusID;
private String FOStatusCode;
private int JobStatusID;
private String JobStatusCode;
private int LocationID;
private String LocationName;
private int RoomTypeID;
private String RoomType;
private int SectionID;
private String GuestID;
private String GuestName;
private String VIPCode;
private String Pax;
private String ArrivalTime;
private String CheckInTime;
private String CheckOutTime;
private String QueueSince;
private Trace[] arrTraces;
private String Specials;
private String ReservationComments;
private String SupervisorComments;
private String HKNotes;
private String TaskSheetName;
private int StandardCleaningTime;
private int AttendantPriority;
private String SupervisorPriority;
private String TaskStartTime;
private String TaskEndTime;
private String TasksheetInstruction;
private String localJobStatusCode;
private Boolean isSynch;
private String credit;
private String RemainingTimeSec;
private String TaskTypeId;
private String AttendantCLTypeId, SupervisorCLTypeId;
private String TritonLocationID;
private String PendingTritonJob;
private Boolean isDiscrepancy, InspectionStatus, IsTaskInspected;
public int getTaskID() {
return TaskID;
}
public void setTaskID(int taskID) {
TaskID = taskID;
}
public int getAttendantID() {
return AttendantID;
}
public void setAttendantID(int attendantID) {
AttendantID = attendantID;
}
public String getAttendentName() {
return AttendentName;
}
public void setAttendentName(String attendentName) {
AttendentName = attendentName;
}
public String getReservationID() {
return ReservationID;
}
public void setReservationID(String reservationID) {
ReservationID = reservationID;
}
public String getResStatusCode() {
return ResStatusCode;
}
public void setResStatusCode(String resStatusCode) {
ResStatusCode = resStatusCode;
}
public int getInspectionStartedById() {
return InspectionStartedById;
}
public void setInspectionStartedById(int inspectionStartedById) {
InspectionStartedById = inspectionStartedById;
}
public String getHKStatusCode() {
return HKStatusCode;
}
public void setHKStatusCode(String hKStatusCode) {
HKStatusCode = hKStatusCode;
}
public int getFOStatusID() {
return FOStatusID;
}
public void setFOStatusID(int fOStatusID) {
FOStatusID = fOStatusID;
}
public String getFOStatusCode() {
return FOStatusCode;
}
public void setFOStatusCode(String fOStatusCode) {
FOStatusCode = fOStatusCode;
}
public int getJobStatusID() {
return JobStatusID;
}
public void setJobStatusID(int jobStatusID) {
JobStatusID = jobStatusID;
}
public String getJobStatusCode() {
return JobStatusCode;
}
public void setJobStatusCode(String jobStatusCode) {
JobStatusCode = jobStatusCode;
}
public int getLocationID() {
return LocationID;
}
public void setLocationID(int locationID) {
LocationID = locationID;
}
public String getLocationName() {
return LocationName;
}
public void setLocationName(String locationName) {
LocationName = locationName;
}
public int getRoomTypeID() {
return RoomTypeID;
}
public void setRoomTypeID(int roomTypeID) {
RoomTypeID = roomTypeID;
}
public String getRoomType() {
return RoomType;
}
public void setRoomType(String roomType) {
RoomType = roomType;
}
public int getSectionID() {
return SectionID;
}
public void setSectionID(int sectionID) {
SectionID = sectionID;
}
public String getGuestID() {
return GuestID;
}
public void setGuestID(String guestID) {
GuestID = guestID;
}
public String getGuestName() {
return GuestName;
}
public void setGuestName(String guestName) {
GuestName = guestName;
}
public String getVIPCode() {
return VIPCode;
}
public void setVIPCode(String vIPCode) {
VIPCode = vIPCode;
}
public String getPax() {
return Pax;
}
public void setPax(String pax) {
Pax = pax;
}
public String getArrivalTime() {
return ArrivalTime;
}
public void setArrivalTime(String arrivalTime) {
ArrivalTime = arrivalTime;
}
public String getCheckInTime() {
return CheckInTime;
}
public void setCheckInTime(String checkInTime) {
CheckInTime = checkInTime;
}
public String getCheckOutTime() {
return CheckOutTime;
}
public void setCheckOutTime(String checkOutTime) {
CheckOutTime = checkOutTime;
}
public String getQueueSince() {
return QueueSince;
}
public void setQueueSince(String queueSince) {
QueueSince = queueSince;
}
public Trace[] getArrTraces() {
return arrTraces;
}
public void setArrTraces(Trace[] arrTraces) {
this.arrTraces = arrTraces;
}
public String getSpecials() {
return Specials;
}
public void setSpecials(String specials) {
Specials = specials;
}
public String getReservationComments() {
return ReservationComments;
}
public void setReservationComments(String reservationComments) {
ReservationComments = reservationComments;
}
public String getSupervisorComments() {
return SupervisorComments;
}
public void setSupervisorComments(String supervisorComments) {
SupervisorComments = supervisorComments;
}
public String getHKNotes() {
return HKNotes;
}
public void setHKNotes(String hKNotes) {
HKNotes = hKNotes;
}
public String getTaskSheetName() {
return TaskSheetName;
}
public void setTaskSheetName(String taskSheetName) {
TaskSheetName = taskSheetName;
}
public int getStandardCleaningTime() {
return StandardCleaningTime;
}
public void setStandardCleaningTime(int standardCleaningTime) {
StandardCleaningTime = standardCleaningTime;
}
public int getAttendantPriority() {
return AttendantPriority;
}
public void setAttendantPriority(int attendantPriority) {
AttendantPriority = attendantPriority;
}
public String getSupervisorPriority() {
return SupervisorPriority;
}
public void setSupervisorPriority(String supervisorPriority) {
SupervisorPriority = supervisorPriority;
}
public String getTaskStartTime() {
return TaskStartTime;
}
public void setTaskStartTime(String taskStartTime) {
TaskStartTime = taskStartTime;
}
public String getTaskEndTime() {
return TaskEndTime;
}
public void setTaskEndTime(String taskEndTime) {
TaskEndTime = taskEndTime;
}
public String getTasksheetInstruction() {
return TasksheetInstruction;
}
public void setTasksheetInstruction(String tasksheetInstruction) {
TasksheetInstruction = tasksheetInstruction;
}
public String getLocalJobStatusCode() {
return localJobStatusCode;
}
public void setLocalJobStatusCode(String localJobStatusCode) {
this.localJobStatusCode = localJobStatusCode;
}
public Boolean getIsSynch() {
return isSynch;
}
public void setIsSynch(Boolean isSynch) {
this.isSynch = isSynch;
}
public String getCredit() {
return credit;
}
public void setCredit(String credit) {
this.credit = credit;
}
public String getRemainingTimeSec() {
return RemainingTimeSec;
}
public void setRemainingTimeSec(String remainingTimeSec) {
RemainingTimeSec = remainingTimeSec;
}
public String getTaskTypeId() {
return TaskTypeId;
}
public void setTaskTypeId(String taskTypeId) {
TaskTypeId = taskTypeId;
}
public String getAttendantCLTypeId() {
return AttendantCLTypeId;
}
public void setAttendantCLTypeId(String attendantCLTypeId) {
AttendantCLTypeId = attendantCLTypeId;
}
public String getSupervisorCLTypeId() {
return SupervisorCLTypeId;
}
public void setSupervisorCLTypeId(String supervisorCLTypeId) {
SupervisorCLTypeId = supervisorCLTypeId;
}
public String getTritonLocationID() {
return TritonLocationID;
}
public void setTritonLocationID(String tritonLocationID) {
TritonLocationID = tritonLocationID;
}
public String getPendingTritonJob() {
return PendingTritonJob;
}
public void setPendingTritonJob(String pendingTritonJob) {
PendingTritonJob = pendingTritonJob;
}
public Boolean getIsDiscrepancy() {
return isDiscrepancy;
}
public void setIsDiscrepancy(Boolean isDiscrepancy) {
this.isDiscrepancy = isDiscrepancy;
}
public Boolean getInspectionStatus() {
return InspectionStatus;
}
public void setInspectionStatus(Boolean inspectionStatus) {
InspectionStatus = inspectionStatus;
}
public Boolean getIsTaskInspected() {
return IsTaskInspected;
}
public void setIsTaskInspected(Boolean isTaskInspected) {
IsTaskInspected = isTaskInspected;
}
}
But it is giving class cast exception when I try to cast it to my data object.
Please help me to resolve this?
You are putting in an Array and expecting out a single object. Also, use ArrayList which is serializable.
Not sure what your TasksheetData class is, but maybe you should use your alltasks as a ParcelableArray instead.
Checkout this
Your array of TasksheetData is definitely not an instance of one Serializable class...