Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created March 20, 2022 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/38b5b711d4296e3c11881708a2418aca to your computer and use it in GitHub Desktop.
Save le0nidas/38b5b711d4296e3c11881708a2418aca to your computer and use it in GitHub Desktop.
fun Parcelable.sizeInBytes(): Int {
val parcel = Parcel.obtain()
try {
parcel.writeParcelable(this, 0)
return parcel.dataSize()
} finally {
parcel.recycle()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment