Why there is function: CharSequence#substring?


I spent a whole day to detect a strange hidden bug in Android app.

Caused by use CharSequence#substring instead of String#substring by accident. Thanks god I finally finished this pain.

I think this function named substring is confusing: it calls subSequence then toString.


Why do you think substring defined this way is confusing? What was your bug with it?


The bug is about custom span, .
because SpannableString implements CharSequence, but sp.substring() is different to sp.toString().substring().
Or in other words,
sp.subSequence().toString() is confusing with sp.toString().substring().


In what situations these two expressions can produce different result?


Because the implements of subSequence is not about String.
SpannableString may cause different effect sometimes, it’s strange. Always post measures to UI thread but nothing happens on screen.