我正在尝试在Quickblox中检索消息创建者的用户名。
我能够使用message.getFrom();
检索用户的ID,但无法通过使用User ID#或消息本身来弄清楚如何获取用户名。对此的任何帮助将不胜感激。
chat.addChatMessageListener(new ChatMessageListener() {
@Override
public void processMessage(Message message) {
Log.i("QB LOG", "Message : " + message.getBody());
//Get userID from message
int userIdNo = Integer.parseInt(message.getFrom());
//Would like to be able to retrieve user name here <---
}
@Override
public boolean accept(Message.Type type) {
switch (type) {
case chat:
return true; // process 1-1 chat messages
default:
return false;
}
}
});
答案 0 :(得分:0)
String from = message.getFrom();
int participantId = Integer.valueOf(QBChatUtils.parseQBUser(from));
QBUsers.getUser(participantId, new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
if (result.isSuccess()) {
QBUserResult qbUserResult = (QBUserResult) result;
Log.i(TAG, ">>> User: " + qbUserResult.getUser().getFullName()