سؤال

i was trying to send my object class GastronomyElement to another activity but i have got this error

java.lang.RuntimeException: Parcelable   encountered IOException writing serializable    object (name =    com.example.despegarteproject.classes.GastronomyElement)

i have seen another posts like this but i couldn not solve it. this is my class code

 public class GastronomyElement implements Serializable {

    String id, name, formattedAddress, formattedPhoneNumber,  reference, photo;
    List<String> photos;
    Boolean openNow;
    Horarios horarios;
    List<Review> reviews;
    String priceLevel;
    double  latitude, longitude;
    Double rating;

    public String getName () {
        return name;
    }

    public void setName (String name) {
        this.name = name;
    }

    public String getId () {
        return id;
    }

    public void setId (String id) {
        this.id = id;
    }

    public String getFormattedAddress () {
        return formattedAddress;
    }

    public void setFormattedAddress (String formattedAddress) {
        this.formattedAddress = formattedAddress;
    }

    public String getReference () {
        return reference;
    }

    public void setReference (String reference) {
        this.reference = reference;
    }

    public String getPhoto () {
        return photo;
    }

    public void setPhoto (String photo) {
        this.photo = photo;
    }

    public List<String> getPhotos () {
        return photos;
    }

    public void setPhotos (List<String> photos) {
        this.photos = photos;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude (double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude (double longitude) {
        this.longitude = longitude;
    }

    public Double getRating () {
        return rating;
    }

    public void setRating (Double rating) {
        this.rating = rating;
    }

    public Boolean getOpenNow () {
        return openNow;
    }

    public void setOpenNow (Boolean openNow) {
        this.openNow = openNow;
    }

    public Horarios getHorarios () {
        return horarios;
    }

    public void setHorarios (Horarios horarios) {
        this.horarios = horarios;
    }

    public String getPriceLevel () {
        return priceLevel;
    }

    public void setPriceLevel (String priceLevel) {
        this.priceLevel = priceLevel;
    }

    public String getFormattedPhoneNumber () {
        return formattedPhoneNumber;
    }

    public void setFormattedPhoneNumber (String formattedPhoneNumber) {
        this.formattedPhoneNumber = formattedPhoneNumber;
    }

    public List<Review> getReviews () {
        return reviews;
    }

    public void setReviews (List<Review> reviews) {
        this.reviews = reviews;
    }

    }

and this is how i am sending it

Intent act = new Intent (context, ActivityLugarDetalles.class);
act.putExtra("elementDetails", elementDetails);
startActivity(act);

i would appreciate your help! thank you!

هل كانت مفيدة؟

المحلول

Since GastronomyElement contains objects of type Horarios and Review, those classes (and any fields they contain, recursively) must also implement Serializable. The exception is probably because one of these classes (or some data contained in one of those classes) fails to implement Serializable. (The other fields of GastronomyElement all implement Serializable already.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top