Q:

Android How to pass Object User to fragment from activity

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.

A:

            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);

