How to send emoji in intent to whatsapp?
Asked Answered
B

2

7

I know that we can send plain text to whatsapp through an intent like :

 Intent sendIntent = new Intent();
 sendIntent.setAction(Intent.ACTION_SEND);
 sendIntent.putExtra(Intent.EXTRA_TEXT,"Text to be sent on whatsapp");
 sendIntent.setType("text/plain");
 sendIntent.setPackage("com.whatsapp");
 startActivity(sendIntent);

But I want to be able to send emojis (emoticons) to whatsapp through an intent.
How is it possible? Do we have some special codes for the emojis?

Bookseller answered 5/10, 2016 at 4:57 Comment(2)
You can check here.how to do this...Driver
I want to be able to send emojis to the whatsapp through intent. This link you shared doesn't help.Bookseller
Q
1

I used StringBuilder for this like:

int unicode = 0x1F600
StringBuilder s = new StringBuilder();
s.append("YOUR MESSAGE HERE");
s.append(Character.toChars(unicode));

The resulting string will be something like this

YOUR MESSAGE HERE😀

Copy the unicode from here But remember to change the code that you will copy from this webpage from U-1F600 to 0x1F600.

U-1F600 is the unicode but android doesn't recognizes this. 0x1F600 is the hexcode for android.

Qualifier answered 10/9, 2020 at 16:7 Comment(0)
M
0

Use this instead of using StringBuilder

 // send message with emojis
       int waveEmojiUnicode = 0x1F44B,
           clapEmojiUnicode = 0x1F44F,
           faceTongueEmojiUnicode = 0x1F60B;
        
            char[] waveEmojiChars = Character.toChars(waveEmojiUnicode);
            char[] clapEmojiChars = Character.toChars(clapEmojiUnicode);
            char[] faceTongueEmojiChars = Character.toChars(faceTongueEmojiUnicode);
        
            String s1 = "Hi Noah ", s2 = ", TimeLY is a nice app ", s3 = ". However, I would like" + " to report a bug [ ... ]. My name is [ ... ] by the way.";
        
            String message = s1 + String.valueOf(waveEmojiChars) + s2 + String.valueOf(clapEmojiChars) + s3 + String.valueOf(faceTongueEmojiChars);

     Intent sendIntent = new Intent();
     sendIntent.setAction(Intent.ACTION_SEND);
     sendIntent.putExtra(Intent.EXTRA_TEXT, message);
     sendIntent.setType("text/plain");
     sendIntent.setPackage("com.whatsapp");
     startActivity(sendIntent);
Manolete answered 13/6, 2021 at 10:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.