以下代码是用 onResume 编写的,正在实现 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");
}
});
}
我在 Android 监视器中没有得到任何日志输出,除了说“在恢复中”的那个。