parcelable

Passing arraylist of objects between activities

纵饮孤独 提交于 2019-11-25 22:25:50
I am trying to pass an arraylist of objects between two activities, but my app crushes at the second activity. Can someone help me solve this problem... Here is my code from my first activity: Intent i = new Intent(); Bundle b = new Bundle(); b.putParcelableArrayList("songs",(ArrayList<? extends Parcelable>) albumsArray.get(position).getSongs()); Log.v("--", "OK"); i.putExtras(b); i.setClass(LatestAlbums.this, AlbumDetails.class); startActivity(i); And code from the second activity: songs=new ArrayList<Songs>(); Bundle b = this.getIntent().getExtras(); if(b!=null) songs = b.getParcelable(