Code example for Spanned

Methods: getSpanEnd, getSpans

0
        //   - add an auto-complete contact 
        //   - add another auto-complete contact 
        //   - delete that second contact and keep deleting into the first 
        //   - we lose the annotation and can no longer get the span. 
        // Need to fix this case because it breaks auto-complete contacts with commas in the name. 
        Annotation[] a = sp.getSpans(start, end, Annotation.class);
        if (a.length > 0) {
            return sp.getSpanEnd(a[0]);
        } 
        return 0; 
    } 
 
    private static String getFieldAt(String field, Spanned sp, int start, int end,
            Context context) {
        Annotation[] a = sp.getSpans(start, end, Annotation.class);
        String fieldValue = getAnnotation(a, field);
        if (TextUtils.isEmpty(fieldValue)) {
            fieldValue = TextUtils.substring(sp, start, end);
        } 
        return fieldValue;