1

I'm trying to pass array of (objects) unfortunately (as far as i know) serializable bundle will not work with custom objects.

I have class seat:

   public class seat{
    boolean state;
    int Seatb;
    }

And here is a code from the first activity:

seat [][] arrseat=new seat[20][20];
Intent intent = new Intent(this, MainActivity2.class);
intent.putExtra("data", arrseat);
startActivity(intent);

Second activity:

seat [][] obseat=new seat[20][20];
Intent intent = getIntent();
obseat=intent.?

I could not find a way to get the array from intent

kalebora
  • 111
  • 1
  • 1
  • 9

1 Answers1

2

Arrays are serializable, So you can use putSerializable. to put value

Intent i = new Intent(this, AnotherClass.class);
Bundle b = new Bundle();
b.putSerializable("arr", seat);
i.putExtras(b);

to get value

seat[][] arrseat = (seat[][]) bundle.getSerializable("arr");

also it is a similar problem here

Community
  • 1
  • 1
noman404
  • 928
  • 1
  • 8
  • 23