0

I have two activity the first activity say Activity1 just gets data from a server filters it and saves it in an arraylist of parcelable objects while displaying a loading screen. After that, Activity1 passes the data it gathered to Acitivty2 which displays it into 2 child fragments.

My problem is that when the list of data in activity1 is few it is successfully passed to activity2 however when it is not, acitivity 2 wont display and starts my other acitivty which is the MainAcitivty instead.

Here is the function I used to start my Activity2 from Activity1

Bundle mBundle = new Bundle();       
Intent intent = new Intent(Activity_Viewdata_loader.this, Activity_Viewdata.class);
mBundle.putParcelableArrayList("myList", sneardatalist);
intent.putExtras(mBundle);

and here is my Activity2 which is the receiver

Bundle mBundle = getIntent().getExtras();
sneardatalist= mBundle.getParcelableArrayList("myList"); 

and my parcelable class looks like this

public class sentdata implements Parcelable  {

    private int _id;
    private String _data="";
    private String _lat="";
    private String _long="";
    private String _img="";
    private String _imgP="";
    private int _sntvia;
    private String _snttime="";
    private String _template="";

    public sentdata(){}
    public sentdata( String data, String lat, String longt, String img, String imgp, int sntvia, String sntime, String template  ){
        this._data = data;
        this._lat = lat;
        this._long = longt;
        this._img = img;
        this._imgP = imgp;
        this._sntvia = sntvia;
        this._snttime = sntime;
        this._template = template;
    }

    public sentdata( int id, String data, String lat, String longt, String img, String imgp, int sntvia, String sntime, String template  ){
        this._id = id;
        this._data = data;
        this._lat = lat;
        this._long = longt;
        this._img = img;
        this._imgP = imgp;
        this._sntvia = sntvia;
        this._snttime = sntime;
        this._template = template;
    }

    public int getid(){
        return this._id;
    }

    public void setid(int id){
         this._id = id;
    }
    public void setdata(String data){
        this._data = data;
    }

    public String getdata(){
        return this._data;
    }

    public void setlat(String lat){
        this._lat = lat;
    }

    public String getlat(){
        return this._lat;
    }

    public void setlong(String longt){
        this._long = longt;

    }

    public String getlong(){
        return this._long;
    }

    public void setimg(String img){
        this._img = img;

    }

    public String getimg(){
        return this._img;

    }

    public void setimgP (String imgP){
        this._imgP = imgP;
    }

    public String getimgP(){
        return this._imgP;
    }

    public void setsentvia(int sntvia){
        this._sntvia = sntvia;
    }

    public int getsentvia(){
        return this._sntvia;
    }

    public void setsentTime(String sentime ){
        this._snttime = sentime;
    }

    public String getsenttime(){
        return this._snttime;
    }

    public void settemp (String tmp ){
        this._template = tmp;
    }

    public String gettmp(){
        return this._template;
    }

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    public sentdata(Parcel source){
        _id = source.readInt();
        _data = source.readString();
        _lat = source.readString();
        _long = source.readString();
        _img = source.readString();
        _imgP = source.readString();
        _sntvia = source.readInt();
        _snttime = source.readString();
        _template = source.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // TODO Auto-generated method stub
        dest.writeInt(_id);     
        dest.writeString(_data);
        dest.writeString(_lat);
        dest.writeString(_long);
        dest.writeString(_img);
        dest.writeString(_imgP);
        dest.writeInt(_sntvia);
        dest.writeString(_snttime);
        dest.writeString(_template);
    }

    public static final Parcelable.Creator<sentdata> CREATOR = new Parcelable.Creator<sentdata>() {

        @Override
        public sentdata createFromParcel(Parcel source) {
            // TODO Auto-generated method stub
            return new sentdata(source);
        }

        @Override
        public sentdata[] newArray(int size) {
            // TODO Auto-generated method stub
            return new sentdata[size];
        }   
    };
}

Please help me.. I don't really know what to do. I have other methods in mind but I don't want to let go of this simple method just because of the size of the data. There might be something else that I must do or don't know yet, Why it wont pass large size arraylist.

Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
ErenRavenHeart
  • 281
  • 3
  • 6
  • 15

1 Answers1

1

Create a class with arraylist of parcelable objects set the parcelable objects to arraylist and pass that class object to the next activity through the bundle.