Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:30:14+00:00 2026-06-05T04:30:14+00:00

I am doing a small project which send message with emotion icons.i use following

  • 0

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 ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:30:15+00:00Added an answer on June 5, 2026 at 4:30 am

    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 enter image description here” as “i am happy :-)” Then When i received the message i check for pattern 🙂 and i replace it with enter image description here.

    here is how i replace

    public static CharSequence addSmileySpans(Context context, CharSequence your_recieved_message) {
        HashMap<Integer, String> smilyRegexMap = new HashMap<Integer, String>();
    
        smilyRegexMap.put(R.drawable.android_smile, ":-\\)");
    
    
        SpannableStringBuilder builder = new SpannableStringBuilder(your_recieved_message);
        @SuppressWarnings("rawtypes")
        Iterator it = smilyRegexMap.entrySet().iterator();
        while (it.hasNext()) {
            @SuppressWarnings("rawtypes")
            Map.Entry pairs = (Map.Entry) it.next();
            Pattern mPattern = Pattern.compile((String) pairs.getValue(),
                    Pattern.CASE_INSENSITIVE);
            Matcher matcher = mPattern.matcher(your_recieved_message);
            while (matcher.find()) {
                Bitmap smiley = BitmapFactory.decodeResource(
                        context.getResources(), ((Integer) pairs.getKey()));
                builder.setSpan(new ImageSpan(smiley), matcher.start(),
                        matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        return builder;
    }
    

    then set the return value of the function on your TextView something like

    messageTextView.setText(addSmileySpans(context,"i iam happy :-)"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small- to medium-size project that I am doing for my software
I am doing a school project regarding a small website that uses php. I
After doing some research I need some advice. This is a small project which
I'm just new to C++, and doing a small project which implementing some inheritance.
I am doing a Internet Gaming project which involving keeping sending small size of
I am doing a small reporting project that needs to read a lot of
I've got a small Java program that I'm developing for a project, which pulls
I'm working on a small hobby project for personal use, which requires a way
I'm currently trying to teach myself PHP by doing a small image-processing type project
Just doing a small project relating to google maps. Basically I have coordinates in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.