spanned From Byte Array - Android android.text

Android examples for android.text:Spanned

Description

spanned From Byte Array

Demo Code


//package com.java2s;

import android.os.Parcel;

import android.text.Spanned;
import android.text.TextUtils;

public class Main {
    public static Spanned spannedFromByteArray(byte[] byteArray) {
        if (byteArray == null) {
            return null;
        }/*from   w  ww  .j a v a  2  s  .c o m*/
        Parcel obtain = Parcel.obtain();
        obtain.unmarshall(byteArray, 0, byteArray.length);
        obtain.setDataPosition(0);
        Spanned result = (Spanned) TextUtils.CHAR_SEQUENCE_CREATOR
                .createFromParcel(obtain);
        obtain.recycle();
        return result;
    }
}

Related Tutorials