I am doing a small project which send message with emotion icons.i use following function that converts image to spannble string to send emotion icon as text but problem is that receiver is unable to see emotion icon on his message instead of emotion icon receiver sees [h]????
public SpannableStringBuilder addSmily(int position){
Drawable happySmileys = mContext.getResources().getDrawable(mThumbIds[position]);
happySmileys .setBounds(0, 0, happySmileys.getIntrinsicWidth(), happySmileys.getIntrinsicHeight());
/*Drawable sadSmiley = this.getResources().getDrawable(R.drawable.progress_4);
sadSmiley .setBounds(0, 0, sadSmiley.getIntrinsicWidth(), sadSmiley.getIntrinsicHeight());*/
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append("[h]");
builder.setSpan(new ImageSpan(happySmileys), builder.length()-"[h]".length(), builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
}
Thanks for reading my question. any suggestion ??
Thanks Babibu for your concept. After some research, I found the solution
here is how i implement.
my application send message for example “i am happy
” as “i am happy :-)” Then When i received the message i check for pattern 🙂 and i replace it with
.
here is how i replace
then set the return value of the function on your TextView something like