RuntimeException:使用Parcel的错误数组长度

时间:2014-09-30 10:39:02

标签: android parcel

有人能够告诉我这样一个简单的代码如何抛出" RuntimeException:错误的数组长度"在线" in.readLongArray(longArray);",非常罕见,我从来没有能够重现它,但在崩溃报告中看到它。

    private long issueId;

    /**
     * compliance for Parcelable
     */
    public Download() {}

    //parcelling part
    public Download (Parcel in) {
        long[] longArray = new long[1];
        in.readLongArray(longArray);
        this.issueId = longArray[0];
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLongArray(new long[] {this.issueId});
    }

    public static final Parcelable.Creator<Download> CREATOR = new Parcelable.Creator<Download>() {
        public Download createFromParcel(Parcel in) {
            return new Download(in);
        }
        public Download[] newArray(int size) {
            return new Download[size];
        }
    };

0 个答案:

没有答案