0

I want to move an adapter object from one activity to another.

My main activity:


                Intent intent = new Intent(MainActivity.this, ActivityTest.class);
                intent.putExtra("Key1", position);
                intent.putExtra("key2", toyAdapter);
                startActivity(intent);

My second activity:

Intent intent = getIntent();
                int position = intent.getIntExtra("Key1", 0);
                ToyAdapter toyAdapter = (ToyAdapter) intent.getSerializableExtra("Key2");

I know something's wrong but I am pretty new to this and therefore I am not sure what's the right way to move that Adapter Object to my second activity. Thanks

ilay
  • 13
  • 2
  • You should really take a look at https://stackoverflow.com/questions/2736389/how-to-pass-an-object-from-one-activity-to-another-on-android – hanut Jan 04 '22 at 11:24
  • @hanut I tried looking at it already but it seems to not work for me. I thought it might have something to do with the object's type being an Adapter but I am not sure how to fix it – ilay Jan 04 '22 at 11:27
  • Is this a recycler view adapter that you want to pass between activities? – Mobin Yardim Jan 04 '22 at 12:15

0 Answers0