1

The following code is written in onResume and is implementing the receive message functionality of SendBird API

protected void onResume()
{
super.onResume();
Log.d("----->", "in on resume");
SendBird.addChannelHandler("ABCD" , new SendBird.ChannelHandler()
{
@Override
public void onMessageReceived(BaseChannel baseChannel, BaseMessage 
baseMessage)
{
Log.d("----->","onMessageReceived");
if (baseMessage instanceof UserMessage)
{
// message is a UserMessage
UserMessage userMessage = (UserMessage) baseMessage;
String msg = userMessage.getMessage();
alMsgs.add(msg);
adapter.notifyDataSetChanged();
Log.d("---->",msg);
}
else if (baseMessage instanceof FileMessage)
{
// message is a FileMessage
}
}
@Override
public void onChannelDeleted(String channelUrl, 
BaseChannel.ChannelType channelType)
{
super.onChannelDeleted(channelUrl, channelType);
Log.d("---->","on channel deleted");
}
});
}

I don't get any Log output in Android Monitor Except the one that says "in on resume".

  • Are you actually receiving messages? i.e. is someone sending messages to you? `onMessageReceived()` is a callback function triggered only when messages are received. – terryk Apr 28 '17 at 01:09
  • No, I am sending the message in the channel. After it is sent, Shouldn't it be received in the same channel by me? – Sameena Bhatia Apr 28 '17 at 01:15
  • You don't receive your own messages. When you send a message with `channel.sendUserMessage()`, the proper way to handle it is using a `SendUserMessageHandler` and overriding the `onSent()` callback, which is called when the message has been successfully sent. – terryk Apr 28 '17 at 01:22
  • 1
    Thank you so much. That really helps. – Sameena Bhatia Apr 28 '17 at 01:29

0 Answers0