code: public static void dumpSpans(CharSequence cs, Printer printer, String prefix) {
          if (cs instanceof Spanned) {
              Spanned sp = (Spanned) cs;
              Object[] os = sp.getSpans(0, cs.length(), Object.class);
  
              for (int i = 0; i < os.length; i++) {
                  Object o = os[i];
                  printer.println(prefix + cs.subSequence(sp.getSpanStart(o),
                          sp.getSpanEnd(o)) + ": "
                          + Integer.toHexString(System.identityHashCode(o))
                          + " " + o.getClass().getCanonicalName()
                           + " (" + sp.getSpanStart(o) + "-" + sp.getSpanEnd(o)
                           + ") fl=#" + sp.getSpanFlags(o));
              }
          } else {
              printer.println(prefix + cs + ": (no spans)");
          }
      }
docs: Debugging tool to print the spans in a CharSequence.  The output will
  be printed one span per line.  If the CharSequence is not a Spanned,
  then the entire string will be printed on a single line.