如何向whatsapp发送表情符号?

时间:2016-10-05 04:57:57

标签: android android-intent whatsapp emoji emoticons

我知道我们可以通过以下意图将纯文本发送到whatsapp:

 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);

但我希望能够通过意图将表情符号(表情符号)发送到whatsapp。
怎么可能? 我们有一些表情符号的特殊代码吗?

2 个答案:

答案 0 :(得分:0)

我像这样使用StringBuilder:

def skip_elements(elements):
    # Initialize variables
    new_list = []
    i = 0

    # Iterate through the list
    for words in elements:
        # Does this element belong in the resulting list?
        if i <= len(elements):
            # Add this element to the resulting list
            new_list.insert(i,elements[i])
        # Increment i
        i += 2

    return new_list

结果字符串将是这样

此处的信息M

here复制unicode 但是请记住,将从该网页复制的代码从U-1F600更改为0x1F600。

U-1F600是unicode,但android无法识别。 0x1F600是android的十六进制代码。

答案 1 :(得分:0)

使用它而不是使用 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);