问题
when i pass an array between intents as a result to startActivityForResult I get a partial array back
ArrayList<User> currentUsers = ...
Intent resultIntent = new Intent();
resultIntent.putParcelableArrayListExtra(USER_ARR, currentUsers);
setResult(Activity.RESULT_OK, resultIntent);
ArrayList<User> users = data.getParcelableArrayListExtra(USER_ARR);
User implements Parcelable, and it is built correct for sure,
I changed something in the passing of the array and now when it sends the array
it is received on other side with many users being null, or all but one user being null
I also tried sending just a Parcelable[], and that did the same thing
please help
回答1:
found the answer :) I have no idea how it worked before fixing this
I was reading a byte array inside my parcelable only if the size of the byte array was bigger than zero, but not reading it did not advance the dataPosition()
thanks to this question Make custom Parcelable containing byte array I found the answer
have a great day everybody
来源:https://stackoverflow.com/questions/18469267/parcelable-arraylist-passed-partially-with-null-elements