quickblox OnMessageListener未收到带附件的qbprivate消息

时间:2017-04-27 16:00:13

标签: android quickblox

我之前已经成功实施了quickblox for android安卓应用程序,仅用于文本聊天。这次我想发送带有图像作为附件的消息。文件发送成功(我在quickblox管理内容面板中检查过)。但在接收器部分,它不显示图像或文本。我在logcat中得到也没有任何异常/错误或文本。因此,我很难找出错误的代码。请帮助。 MyChatControlle ------------------------`私人QBPrivateChatManagerListener chatManagerListener = new QBPrivateChatManagerListener(){         @覆盖         public void chatCreated(QBPrivateChat qbPrivateChat,boolean b){             if(!b){                 qbPrivateChat.addMessageListener(myListener的);             }         }

};`

private QBMessageListener myListener=new QBMessageListener() {
    @Override
    public void processMessage(QBChat qbChat, QBChatMessage qbChatMessage) {
        int frm=qbChatMessage.getSenderId();
        int tos=qbChatMessage.getRecipientId();
        System.out.println(String.format(">>> Message received (from=%s, to=%s): %s", frm, tos, qbChatMessage.getBody()));
        if (onMessageReceivedListener != null) {
            onMessageReceivedListener.onMessageReceived(qbChatMessage);
        }
    }
    @Override
    public void processError(QBChat qbChat, QBChatException e, QBChatMessage qbChatMessage) { }

};

ChatActivity

 MyChatController.OnMessageReceivedListener onMessageReceivedListener = new MyChatController.OnMessageReceivedListener() {
    @Override
    public void onMessageReceived(final QBChatMessage msg) {
        try {
            final String mmsg = msg.getBody();
            Toast.makeText(getApplicationContext(), "Receiving..."+mmsg, Toast.LENGTH_LONG).show();
        }catch (Exception e){
            Toast.makeText(getApplicationContext(),"#A#B#"+e.toString(), Toast.LENGTH_LONG).show();
        }
    }
};

1 个答案:

答案 0 :(得分:0)

您可以在没有聊天管理器的情况下使用最新版本的QuickBlox Android SDK。在最新版本中,您可以使用QBChatDialog模型来执行所有聊天功能。另外,检查附件的所有参数,它们不是空的而不是空的。你能提供一些消息,它不被监听器捕获(来自logcat的.xml)吗?