Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: problem with Serializable object put into intent

Hi i have problem with a class i want to pass in an intent by putting it into the putExtras() Its serializable and the code looks like this:

public abstract class ObjectA extends ArrayList<ObjectA> implements java.io.Serializable{...}

public class ObjectB extends ObjectA {...}


...
Bundle extras = new Bundle();
extras.putSerializable("blabla", ObjectB);
intent.putExtras(extras);

...

Object y = getIntent().getExtras().get("blabla");

the problem is, that y now is an ArrayList and no longer an ObjectB so i cant cast it.. if i change the code to

public class ObjectB implements java.io.Serializable {...}

it works fine

like image 269
Simon Avatar asked Oct 10 '09 17:10

Simon


1 Answers

By implementing both java.util.List and java.io.Serializable in your class you've triggered this android bug.

like image 181
Pavel Lapin Avatar answered Sep 21 '22 18:09

Pavel Lapin