Parcelable, what is newArray for?

后端 未结 3 1941
深忆病人
深忆病人 2021-02-14 11:02

I am implementing Parcelable in order to transmit some simple data throughout an Intent.
However, There is one method in the Parcelable interface that I don\'t understand at

3条回答
  •  半阙折子戏
    2021-02-14 11:33

    It is there to prepare the typed array without all the generics stuff. That's it.
    Returning just the standard return new MyParcelable[size]; is fine.

    It is normal, that you never call it yourself. However, by calling something like Bundle.getParcelableArray() you end up in this method indirectly.

提交回复
热议问题