简体   繁体   English

使用smack Api在消息文本中添加和检查图释-Android

[英]Adding and checking the emoticon in the message text using smack Api - Android

I am working on chat application using smack api in android. 我正在使用Android中的smack api开发聊天应用程序。 How can i send the Emoticons in between or end of the text of message body using smack? 如何使用smack在邮件正文之间或邮件末尾发送表情符号? And for received messages also how can i detect that text text has Emoticons some where in the text. 对于收到的消息,我还如何检测到文本中的某些地方有表情符号。 I have referred this link http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/xhtml.html 我已将此链接http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/xhtml.html引用

Is this is only way or correct way of sending and receiving the Emoticons? 这是发送和接收表情的唯一方法还是正确的方法?

ISSUE 2: How can i detect that i had lost my connection XMPP server. 问题2:如何检测到我丢失了连接XMPP服务器。 Can any one had the Idea Please share your ideas 任何人都可以提出想法吗?请分享您的想法

You can detect if the XMPP connection has lost using the following listener in Android 您可以在Android中使用以下侦听器来检测XMPP连接是否丢失

connection.addConnectionListener(new ConnectionListener() {
    @Override
    public void reconnectionSuccessful() {
        // TODO Auto-generated method stub
        System.out.println("ConnectionListener ==== >>>>> reconnectionSuccessful");
    }

    @Override
    public void reconnectionFailed(Exception arg0) {
        // TODO Auto-generated method stub
        System.out.println("ConnectionListener ==== >>>>> reconnectionFailed >>> " + arg0.toString());
    }

    @Override
    public void reconnectingIn(int arg0) {
        // TODO Auto-generated method stub
        System.out.println("ConnectionListener ==== >>>>> reconnectingIn >>> " + arg0);
    }

    @Override
    public void connectionClosedOnError(Exception arg0) {
        // TODO Auto-generated method stub
        System.out.println("ConnectionListener ==== >>>>> connectionClosedOnError >>>" + arg0.toString());

    }

    @Override
    public void connectionClosed() {
        // TODO Auto-generated method stub
        System.out.println("ConnectionListener ==== >>>>> connectionClosed");
    }
});

Use this library for emojicons: 将此库用于表情符号:

https://github.com/rockerhieu/emojicon https://github.com/rockerhieu/emojicon

remember to do Base64 encoding while you send packets over XMPP. 通过XMPP发送数据包时,请记住进行Base64编码。 Without Base64 encoding there are chances that the XMPP connection get loss all the time. 如果没有Base64编码,则XMPP连接可能会一直丢失。

Happy coding !! 快乐编码! :) :)

Your question depends on two main things; 您的问题取决于两点:

  1. are all your users using your client? 您的所有用户都在使用您的客户端吗?
  2. do you want to use a whole load of emoticons or just the standard ones? 您要使用全部表情符号还是仅使用标准表情符号?

If your users are all using your client you can implement it anyway you like. 如果您的用户都在使用您的客户端,则可以随时执行它。 Another possible method would be to come up with character patterns to place in the message body that would be picked up by a regex pattern searcher, though this would get convoluted if you used more than a few emoticons. 另一种可能的方法是将字符模式放置在邮件正文中,然后由正则表达式模式搜索器将其拾取,但是如果您使用了多个表情符号,则可能会令人费解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM