Can you tell me how to pass the data through Intent?



  • public class MarkerList{
    
        public MarkerList(int capacity) {
            super(capacity);
        }
    
        public MarkerList() {
        }
    
        public MarkerList(Collection collection) {
            super(collection);
        }
    
        ArrayList<String> lat=new ArrayList<>();
        ArrayList<String> lng=new ArrayList<>();
        ArrayList<String> name=new ArrayList<>();
        ArrayList<String> type_2=new ArrayList<>();//Type_2
    
        public int getSize(){
            return name.size();
        }
    
        public ArrayList<String> getLat() {
            return lat;
        }
    
        public void setLat(ArrayList<String> lat) {
            this.lat = lat;
        }
    
        public ArrayList<String> getLng() {
            return lng;
        }
    
        public void setLng(ArrayList<String> lng) {
            this.lng = lng;
        }
    
        public ArrayList<String> getName() {
            return name;
        }
    
        public void setName(ArrayList<String> name) {
            this.name = name;
        }
    
        public ArrayList<String> getType_2() {
            return type_2;
        }
    
        public void setType_2(ArrayList<String> type_2) {
            this.type_2 = type_2;
        }
    }
    

    I have this class. I can't pass through PutExtras. Can you tell me how to pass my class?



  • There's such a great page on which there's no problem making Parcelable: http://www.parcelabler.com/

    Here's your Parcelable class:

    public class MarkerList implements Parcelable {
    

    public MarkerList(int capacity) {
    super(capacity);
    }

    public MarkerList() {
    }

    public MarkerList(Collection collection) {
    super(collection);
    }

    ArrayList<String> lat=new ArrayList<>();
    ArrayList<String> lng=new ArrayList<>();
    ArrayList<String> name=new ArrayList<>();
    ArrayList<String> type_2=new ArrayList<>();//Type_2

    public int getSize(){
    return name.size();
    }

    public ArrayList<String> getLat() {
    return lat;
    }

    public void setLat(ArrayList<String> lat) {
    this.lat = lat;
    }

    public ArrayList<String> getLng() {
    return lng;
    }

    public void setLng(ArrayList<String> lng) {
    this.lng = lng;
    }

    public ArrayList<String> getName() {
    return name;
    }

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

    public ArrayList<String> getType_2() {
    return type_2;
    }

    public void setType_2(ArrayList<String> type_2) {
    this.type_2 = type_2;
    }

    protected MarkerList(Parcel in) {
    if (in.readByte() == 0x01) {
    lat = new ArrayList<String>();
    in.readList(lat, String.class.getClassLoader());
    } else {
    lat = null;
    }
    if (in.readByte() == 0x01) {
    lng = new ArrayList<String>();
    in.readList(lng, String.class.getClassLoader());
    } else {
    lng = null;
    }
    if (in.readByte() == 0x01) {
    name = new ArrayList<String>();
    in.readList(name, String.class.getClassLoader());
    } else {
    name = null;
    }
    if (in.readByte() == 0x01) {
    type_2 = new ArrayList<String>();
    in.readList(type_2, String.class.getClassLoader());
    } else {
    type_2 = null;
    }
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
    if (lat == null) {
    dest.writeByte((byte) (0x00));
    } else {
    dest.writeByte((byte) (0x01));
    dest.writeList(lat);
    }
    if (lng == null) {
    dest.writeByte((byte) (0x00));
    } else {
    dest.writeByte((byte) (0x01));
    dest.writeList(lng);
    }
    if (name == null) {
    dest.writeByte((byte) (0x00));
    } else {
    dest.writeByte((byte) (0x01));
    dest.writeList(name);
    }
    if (type_2 == null) {
    dest.writeByte((byte) (0x00));
    } else {
    dest.writeByte((byte) (0x01));
    dest.writeList(type_2);
    }
    }

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<MarkerList> CREATOR = new Parcelable.Creator<MarkerList>() {
    @Override
    public MarkerList createFromParcel(Parcel in) {
    return new MarkerList(in);
    }

    @Override
    public MarkerList[] newArray(int size) {
        return new MarkerList[size];
    }
    

    };
    }




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2