Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel android.os.Parcel@7c1d390: Unmarshalling unknown type code 2131296439 at offset 1204 #10

Closed
g19980115 opened this issue Nov 28, 2017 · 0 comments

Comments

@g19980115
Copy link

g19980115 commented Nov 28, 2017

大神啊,Parcel 写法不规范,我找了一个上午的问题...
在部分低内存的手机会出现这个情况,可以在开发者选项打开不保留活动模拟低内存
添加describeContents和CREATOR 可以解决问题
完整修改如下:

 static final class SavedState extends BaseSavedState {
        private boolean isOpened;

        SavedState(Parcelable superState) {
            super(superState);
        }

        private SavedState(Parcel in) {
            super(in);
            isOpened = 1 == in.readInt();
        }

        @Override
        public void writeToParcel(Parcel out, int flags) {
            super.writeToParcel(out, flags);
            out.writeInt(isOpened ? 1 : 0);
        }

        //必须
        @Override
        public int describeContents() {
            return 0;
        }
        //必须
        public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
            @Override
            public SavedState createFromParcel(Parcel in) {
                return new SavedState(in);
            }

            @Override
            public SavedState[] newArray(int size) {
                return new SavedState[size];
            }
        };
    }
iielse added a commit that referenced this issue Dec 27, 2017
@iielse iielse closed this as completed Dec 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants