如何使用putExtra()将对象从一个活动发送到另一个活动?

时间:2018-03-19 12:25:57

标签: android android-intent parcelable geopoints

我尝试用parcalebe方法做到这一点,但我无法弄清楚如何将它与地球点一起使用。这是我试图发送的对象。任何帮助都会得到满足。

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];
        }

    };
}

0 个答案:

没有答案