0

I tried to do it with the parcalebe method but i cant figure out how to use it with a geopoint. This is the object im trying to send. Any help would be appriciated.

public class Station implements Parcelable {
    private String description;
    private String linenumber;
    private GeoPoint location;
    private String name;


    public Station(Parcel in) {
        this.description = in.readString();
        this.name = in.readString();
        this.linenumber = in.readString();
        this.location.getLongitude();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.description);
        parcel.writeString(this.name);
        parcel.writeString(this.linenumber);
        parcel.writeDoubleArray(new double[]{this.location.getLatitude(), this.location.getLongitude()});
    }

    public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
        public Station createFromParcel(Parcel in) {
            return new Station(in);
        }

        @Override
        public Station[] newArray(int i) {
            return new Station[i];
        }

    };
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • 1
    Possible duplicate of https://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents – Shalu T D Mar 19 '18 at 12:27
  • 1
    Possible duplicate of [How to send an object from one Android Activity to another using Intents?](https://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents) – Levi Moreira Mar 19 '18 at 12:28
  • Thanks but i already tried this method but it doesnt explain how to use with a geopoint. – Alon Morad Mar 19 '18 at 12:32
  • Check this https://www.sitepoint.com/transfer-data-between-activities-with-android-parcelable/ – matin sayyad Mar 19 '18 at 12:43

0 Answers0