0

class Selected_img_layout:

 Intent i = new Intent(Selected_img_layout.this, ImagSlider.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("image_data", spacecrafts);
                i.putExtras(bundle);
                startActivity(i);

class ImagSlider:

 Bundle bundleobject = getIntent().getExtras();
 spacecrafts = (ArrayList<Spacecraft>) bundleobject.getSerializable("image_data");

class Spacecraft:

public class Spacecraft implements Serializable {
        Uri uri;

        public Spacecraft() {
        }

        public Spacecraft(String name, Uri uri) {
            this.name = name;
            this.uri = uri;
        }

        public Uri getUri() {
            return uri;
        }

        public void setUri(Uri uri) {
            this.uri = uri;
        }
     }

Error

 java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.letsgo.mypdfconverter.Spacecraft)
Kerberos
  • 4,036
  • 3
  • 36
  • 55

2 Answers2

0

replace this:

 public Spacecraft(String name, Uri uri) {
            this.name = name;
            this.uri = uri;
        }

with:

 public Spacecraft( Uri uri) {
            this.uri = uri;
        }
Sam
  • 1
  • 1
0

Try This Code: Intent i = new Intent(Selected_img_layout.this, ImagSlider.class); i.putExtras("image_data",spacecrafts); startActivity(i);

Try This to get Your data in another activity

Spacecraft spaceCraft =(Spacecraft)getIntent().getSerializableExtra("image_data")

Pravin
  • 31
  • 5