简体   繁体   中英

Linphone PeerAddress DisplayName is not being set

I'm creating an app using Linphone. I'm creating a new LinphoneChatRoom using this code:

public void createNewChatRoom(String destination, String name)
{
  LinphoneChatRoom[] rooms = core.getChatRooms();
  for (LinphoneChatRoom room : rooms)
  {
    Log.d("name1: " + room.getPeerAddress().getDisplayName());
  }
  LinphoneChatRoom room = core.getOrCreateChatRoom(destination);
  if (room != null)
  {
    room.getPeerAddress().setDisplayName(name);
  }
  rooms = core.getChatRooms();
  for (LinphoneChatRoom room2 : rooms)
  {
    Log.d("name2: " + room2.getPeerAddress().getDisplayName());
  }
}

During the first iteration on the rooms (name1 iteration) all of the display names I'm getting are null. At the second iteration over the rooms (name2 iteration), There is indeed a new room that was added and the array is +1 in size, but again, all the display names are null even though I just set it. Why is this happening?

After searching for a while I have found that you will only get a displayName if the SIP address used to create the chatRoom contains one.

My problem was I didn't set the displayName when creating the chatRoom, but set it on a variable I got once it has been created (and not on the chatRoom itself).

Here's how to do that:

LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(destination);
addr.setDisplayName(name);
LinphoneChatRoom room = core.getOrCreateChatRoom(addr.asString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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