How to use MucEnterConfiguration in android smack 4.2.0-beta1?

I want to go back to the room and don't want any story, but the DiscussionHistory is out of date. So I found the MucEnterConfiguration class . But I am unable to create a MucEnterConfiguration object .

  • MucEnterConfiguration is the last class, so it cannot be extended and you don't have a public constructor.

  • MucEnterConfiguration.Builder is also the final class, so it cannot be extended and does not have a public constructor.

How can I create an object of it.

thank

+1


source to share


1 answer


EntityBareJid mucJid =  JidCreate.entityBareFrom(roomJid);
Resourcepart nickname = Resourcepart.from(nickname);
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);

MultiUserChat muc = manager.getMultiUserChat(mucJid);
MucEnterConfiguration.Builder mec = muc.getEnterConfigurationBuilder(nickname);

String lastDate = "yourLastDate";
if(lastDate!=null)
{
    try {
        Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(lastDate);
        int secondsBetween = (int) ((new Date().getTime() - date.getTime()) / 1000);
        mec.requestHistorySince(secondsBetween - 1);
    } catch (Exception e) {
        mec.requestNoHistory();
    }
} else {
      mec.requestNoHistory();
}
MucEnterConfiguration mucEnterConfig = mec.build();
muc.join(mucEnterConfig);

      



+3


source







All Articles