2
Intent mIntent = new Intent(Login.this, PlatformActivity.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("user",user);
                mIntent.putExtras(bundle);
                startActivity(mIntent);

public class User implements Serializable {

    private List<UserAccount> userAccountList;
    ...
    ...
}

RuntimeException:Parcelable encountered IOException writing serializable object (name = com.orbis.mobile.User)

User is not serializable , I want to know how to pass Object with arrayList. If user not set userAccountList, it can be worked.

typeof programmer
  • 1,509
  • 4
  • 22
  • 34

2 Answers2

1
            ArrayList<UserAccount> userAccountList = user.getUserAccountList();
            user.setUserAccountList(null);

            bundle.putSerializable("user", user);

            bundle.putSerializable("accountList", userAccountList);

            mIntent.putExtras(bundle);
            startActivity(mIntent);


    user = (User) getIntent().getSerializableExtra("user");

    ArrayList<UserAccount> accountNumberList = (ArrayList<UserAccount>) getIntent().getSerializableExtra("accountList");

    user.setUserAccountList(accountNumberList);
Urchin
  • 464
  • 1
  • 4
  • 14
0

List is not a Serializable interface, you need to use an implementation like ArrayList

See http://docs.oracle.com/javase/7/docs/api/java/util/List.html

and http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

public class User implements Serializable {

    private ArrayList<UserAccount> userAccountList;
    ...
    ...
}

Also UserAccount needs to implements Serializable

Blundell
  • 75,855
  • 30
  • 208
  • 233