0

I am trying to start up an Intent from within a class which implements Serializable. I get a IOException which says "Parcelable encountered IOException wrinting Serializable object". This is what i am trying to do from within a method in the class implementing Serializable:

thisOffer = this;

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

    Intent intent = new Intent(applicationContext, ActivityOffer.class);
    intent.putExtra("offer", thisOffer);

    activity.startActivity(intent);
}
});

Everything works fine i take away the putExtra() method

AlexanderNajafi
  • 1,631
  • 2
  • 25
  • 39

2 Answers2

1

There could be some field within your class which is not implementing Serializable

Ajay George
  • 11,759
  • 1
  • 40
  • 48
  • Thanks that is the problem. Do i have to extend all those classes and make them Serializable, there are many classes. Maybe its better to just send Strings with the information i need. – AlexanderNajafi Aug 14 '12 at 14:48
  • Yes, you do need to make them Serializable or use a custom serialization strategy using writeObject and readObject. If you can keep your data limited to strings that would work just fine. – Ajay George Aug 14 '12 at 15:26
0

You cannot pass whole activity in putExtra like this....

in the putextra method you can pass basic datatype and some other class...

just show the 2nd argument of putExtra method......

  • 1
    the putExtra method can take in a object which implements Serializable. I am not trying to send an Activity object, this class does not even extend Activity. – AlexanderNajafi Aug 14 '12 at 14:49