-1

i have set of values in android listview. when i click submit button i want to get whole list in another activity. i tried with intent.putExtra(); but i am getting following error .

java.lang.RuntimeException: Parcel: unable to marshal value com.example.technical14.recyclers.Planet@4011368 

My Code is -

proceed.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        ArrayList<Planet> apl = planetsList;
        Intent intent = new Intent(MainActivity.this, Proceed.class);
        intent.putExtra("QuestionListExtra", apl);

        startActivity(intent);
    }
});

i am new to the android. so please help me on this.

Komal12
  • 3,340
  • 4
  • 16
  • 25
Karthick Anbazhagan
  • 353
  • 2
  • 9
  • 27

2 Answers2

2

Make Planet Parcelable using http://parcelabler.com/

and then send using

intent.putExtra("QuestionListExtra", apl);

and in Proceed activity

ArrayList<Planet> list = getIntent().getParcelableArrayListExtra("QuestionListExtra");
PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
2

Find the solution

  1. Your model class should be implements Parcelable :

     public class Planet implements Parcelable {
    
    // Your setter and getter methods
     }
    
  2. Put your arralist to putExtra() :

    ArrayList<Planet> contactList = // planets data;
    Intent intent = new Intent(this,DisplayContact.class);
    intent.putExtra("Contact_list", contactList);
    startActivity(intent);
    

3.In second Activity:

    ArrayList<ContactClass> myList = getIntent().getParcelableExtra("Contact_list");
Rajasekhar
  • 2,345
  • 1
  • 13
  • 20