0

My goal is to serialize spanned objects only, without text.

I was very happy to found that all(most of them) Span objects implement Parcelable interface

But it turned out that Android doesn't follow the Parcelable protocol and there is no CREATOR object in their implementations : ParcelableSpan - A special kind of Parcelable for objects that will serve as text spans

Does anyone know the way to serialize Span objects (for example StyleSpan) ?

Mickey Tin
  • 3,408
  • 10
  • 42
  • 71
  • see `android.text.TextUtils` docs – pskink Sep 08 '17 at 14:28
  • HI @pskink, I guess you a referring https://developer.android.com/reference/android/text/TextUtils.html#writeToParcel(java.lang.CharSequence, android.os.Parcel, int) But this thing parcels the whole Text with styles and I wanted only the styles which are not CharSequence – Mickey Tin Sep 08 '17 at 14:29
  • no i am referring the `Creator` – pskink Sep 08 '17 at 14:30
  • ok, how do I use this, please ? there is no description – Mickey Tin Sep 08 '17 at 14:32
  • 1
    see `Parcelable.Creator` [docs](https://developer.android.com/reference/android/os/Parcelable.Creator.html), here you have its implementation: http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/java/android/text/TextUtils.java#678 – pskink Sep 08 '17 at 14:36
  • thanks a lot @pskink I think I can adopt the implementation to skip the actual string from persisting – Mickey Tin Sep 08 '17 at 14:41
  • but the spans cannot flow in the air - they have to be attached to some string – pskink Sep 08 '17 at 14:44
  • I see, I want to pass them between processes and attach them to a string. Hope it's possible – Mickey Tin Sep 08 '17 at 14:50
  • so attach them to an empty string and if its not possible (i saw somewhere that 0 length spans are forbidden) then attach to "_" or something – pskink Sep 08 '17 at 14:54
  • Can I know what's the purpose of that? – azizbekian Sep 08 '17 at 15:55

0 Answers0